0

我想要做的是检查 sheet1、column3 是否有我在 sheet2 上定义为 combobox1.value 的变量。

我希望宏在每次在 sheet2 上的 sheet1 中找到 combobox1 的值以及 2 个偏移值时列出。

我完全迷失了,在堆栈溢出时找不到类似的东西。

      Sub make_list()
Dim grower As String
Dim r As Range
grower = Sheets("Grower Reporting").ComboBox1.Value

Set r = Sheets("Grower Rejection Data").Range("E:E").Find(grower, Range("e1"), _
LookIn:=xlValues, lookat:=xlWhole, searchdirection:=xlNext)
i = 1
If Not r Is Nothing Then
    firstAddress = r.Address
    Do
        'Add cell references to a list on sheet1 column E.
        Sheets("Sheet1").Cells(i, 5).Value = Sheets("Grower Rejection Data").Cells(r.Row, 3).Address
        'Add any additional offset values here
        i = i + 1
        Set r = Sheets("Grower Rejection Data").Range("e:e").FindNext(r)
    Loop While Not r Is Nothing And r.Address <> firstAddress
End If
End Sub

我要做的是检查工作表“Grower Rejection Data”上的 e 列“种植者”变量出现了多少次,并从单元格 h31 开始在工作表“Grower Reporting”上列出每个出现。我希望这有助于让我更清楚地尝试什么。

4

1 回答 1

1

听起来这就是你要找的东西:

Set R = Sheets("Grower Rejection Data").Range("E:E").Find(grower, Range("E1"), _      LookIn:=xlValues, lookat:=xlWhole, searchdirection:=xlNext)
i = 31
If Not R Is Nothing Then
    firstAddress = R.Address
    Do
        Sheets("Grower Reporting").Cells(i, 38).Value = R.Value
        Sheets("Grower Reporting").Cells(i, 39).Value = R.Offset(0,1).Value
        Sheets("Grower Reporting").Cells(i, 40).Value = R.Offset(0,2).Value           
        i = i + 1
        Set R = Sheets("Grower Rejection Data").Range("E:E").FindNext(R)
    Loop While Not R Is Nothing And R.Address <> firstAddress
End If
于 2013-10-04T15:17:39.450 回答