0
我不断收到这个错误的线Application.WorksheetFunction
和阅读这个话题几个小时,我觉得我几乎无处可去。 它与我引用Sheet2的方式有什么关系?或者我不完全了解Application.WorksheetFunction
应该做什么?无法获取WorkSheet函数类的match属性 - 语法?
Sub SearchForValues()
i = 4 'starts the iterator at column D
Do While Cells(1, i) <> ""
Dim l As Long, searchRange As String
n = 2
Do While Range("A" & n) <> "" 'loop until the last row of data in the first column
StartRow = Range("B" & n)
EndRow = Range("C" & n)
searchRange = "A" & StartRow & ":Q" & EndRow
l = Application.WorksheetFunction.Match(Cells(1, i), Worksheets("Sheet2").Range(searchRange), 0)
Range("D" & n) = l
n = n + 1
Loop
i = i + 1
Loop
End Sub
下面是我拥有的数据的屏幕截图。列B和C都是我想在表1 and each cell across the top is a term I want to search for in that range.
比赛仅适用于一个维数组的例子。无论是一行还是一列。 –
@ScottCraner这样做很有道理,谢谢。我可以使用不同的功能来搜索整个范围吗? – eob
使用VBA Find() –