|
こんにちは。かみちゃん です。
>この表から(検索1)(検索2)で検索して、[5]行のセルを選択できる
以下のような感じではいかがでしょうか?
Sub Sample()
Dim ws As Worksheet
Dim ● As Range
Dim ▲ As Range
Dim firstAddress As String
Set ws = ActiveSheet
With ws
Set ● = .Cells.Find("検索1", After:=.Range("A1"), LookAt:=xlWhole, _
SearchOrder:=xlByColumns) '行方向(↓)
If Not ● Is Nothing Then
firstAddress = ●.Address
Do
Set ▲ = ●.EntireRow.Find("検索2", After:=●, LookAt:=xlWhole, _
SearchOrder:=xlByRows) '列方向(→)
If Not ▲ Is Nothing Then
▲.Select
MsgBox ▲.Row & " 行目に見つかりました。"
Exit Do
End If
Set ● = .Cells.FindNext(●)
If ● Is Nothing Then Exit Do
Loop Until ●.Address = firstAddress
Else
MsgBox "検索1が見つかりません"
End If
End With
MsgBox "終了しました"
End Sub
|
|