|
Public Function FindNB(sheetName As String, findName As String, needFind As String)
'这个函数返回一个数组arr
'.........自行添加防错处理
Dim A, B(), i&, s&, c%
c = Cells(1, needFind).Column
A = Sheets(sheetName).Range("a1").CurrentRegion
For i = 2 To UBound(A)
If A(i, 1) = findName Then
s = s + 1
ReDim Preserve B(1 To s)
B(s) = A(i, c)
End If
Next i
FindNB = B
End Function
Sub test()
Dim arr()
arr = FindNB("Sheet1", "笔", "C")
Stop
End Sub
|
|