我有两个子,第一个子“查找”在 G 列范围 (G1:G10) 中查找所有值,我有三个值,所以它循环 3 次并给我值。
现在我正在调用第二个子“Find2”以在 A 列范围 (A1:A10) 中查找该值。问题是它只运行一次.. 它没有循环三次以获得 3 个值。任何想法 ?。为什么它不工作。
Sub Find()
Set shtSheet1 = Sheets("Sheet1")
With shtSheet1.Range("G1:G10")
Set V = .find("*", LookIn:=xlValues)
If Not V Is Nothing Then
FirstAddress = V.Address
Do
X = V
Call Find2
Set V = .FindNext(V)
Loop While Not V Is Nothing And V.Address <> FirstAddress
End If
End With
End Sub
第二个子
Public Sub Find2()
Set shtSheet1 = Sheets("Sheet1")
Set shtSheet2 = Sheets("Sheet2")
With shtSheet1.Range("A1:A10")
Set C = .find(X, LookIn:=xlValues)
If Not C Is Nothing Then
MsgBox X
End If
End With
End Sub