特定の列で下から検索する
 サンプルマクロは、インプットボックスに入力された値をA列で
下から検索します。

Sub Sample()

    Dim myRow As Long
    Dim myClm As Long
    Dim myFindStr As String
    
    myClm = 1   'A列
    myFindStr = InputBox("検索する文字列を入力してください。")
    If myFindStr = vbNullString Then Exit Sub
    myFindStr = "*" & myFindStr & "*"   '一部のみ一致を許可
    
    For myRow = Cells(Rows.Count, myClm).End(xlUp).Row _
        To 1 Step -1
        With Cells(myRow, myClm)
            If .Value Like myFindStr Then
                .Activate
                Exit For
            End If
        End With
    Next

End Sub

Excel95/97/2000



戻る


Excel Word Access VBA! モーグ