文字列検索(全てが一致)   次の文書

Sub Search()
Dim 行 As Long
Dim 列 As Integer
Dim 検索結果 As Object
Dim 検索範囲 As Range
Dim セル As Range

文字 = Cells(1, 4)
行 = 0
列 = 0
Set 検索範囲 = Worksheets("Sheet2").Range("D5:N5")
Set 検索結果 = 検索範囲.Cells.Find(文字, LookAt:=xlWhole)

If Not 検索結果 Is Nothing Then
'--範囲選択の中を探す
For Each セル In 検索範囲
If セル.Value = 検索結果 Then
行 = 検索結果.Cells.Row
列 = 検索結果.Cells.Column
Set 検索結果 = Cells.FindNext(検索結果)
End If
Next セル
Else
MsgBox "見つかりませんでした"
End If

If 行 <> 0 And 列 <> 0 Then
Sheets("sheet2").Select
Range(Cells(行, 列), Cells(行, 列)).Select
End If
End Sub

 



← 左の文字をここへ入力後 登録ボタンをクリックしてください

(サイト管理者承認後掲載されます)