Consulting

Results 1 to 6 of 6

Thread: Search a worksheet

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Search a worksheet

    I have a need to search a list and display the data. I want to search for a name, not case sensitive. Tried to record one and copy it but the macro was empty. Any suggestions?
    Peace of mind is found in some of the strangest places.

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hi Austen,

    Can you explain a little more? Define "search a list". And display the data where? On a new worksheet? In a message box?

  3. #3
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this:


    Option Explicit
    
    Sub Macro1()
    Dim Cel             As Range
    Dim FirstAddress    As String
        With Range("A:A")
            Set Cel = .Find(What:="Test", LookIn:=xlValues, _
            LookAt:=xlWhole, MatchCase:=False)
            If Not Cel Is Nothing Then
                FirstAddress = Cel.Address
                Do
                    MsgBox Cel.Address
                    Set Cel = .FindNext(Cel)
                Loop While Not Cel Is Nothing And Cel.Address <> FirstAddress
            End If
        End With
    End Sub

  4. #4
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Thanks Jake
    Peace of mind is found in some of the strangest places.

  5. #5
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    You may also want to check out this article by Johnske: http://www.vbaexpress.com/forum/arti...rticle&artid=5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •