|
▼庄子 誠 さん:
>SHEET-1のA1に入力をした文字をSHEET-2, SHET-3, SHEET-4から検索
ヒントです
以下の2つのモジュールを組合わせてみてください。
Sub Try1() 'Sheetの巡回
Dim ws As Worksheet
For Each ws In Worksheets(Array("SHEET-2", "SHET-3", "SHEET-4"))
MsgBox "検索範囲は " & ws.UsedRange.Address, , ws.Name
Next
End Sub
Sub Try2() '指定シートの検索 (Findのヘルプの使用例より)
Dim ws As Worksheet
Dim What As String
Dim c As Range
Dim firstAddress As String
What = Worksheets(1).Range("A1").Value
Set ws = Worksheets("SHEET-2")
With ws.UsedRange
Set c = .Find(What, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
firstAddress = c.Address
Do
MsgBox c.Address, , c.Value
Set c = .FindNext(c)
Loop Until c.Address = firstAddress
End If
End With
End Sub
|
|