最初のサブ「検索」は、列 G 、範囲 (G1:G10) のすべての値を検索します。そこには3つの値があるため、3回ループして値を取得します。
今、私は2番目のサブ「Find2」を呼び出して、列Aの範囲(A1:A10)でその値を見つけています。問題は、1 回しか実行されないことです。3 つの値を取得するために 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