Consulting

Results 1 to 3 of 3

Thread: Fill in data from Search routine

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

    Fill in data from Search routine

    How can I fill in an information box with the results from the Search routine. Thank you DRJ for the routine, but I can't seem to get it to work. I am attaching the file for consideration. The data is in a sheet called "DataSheet".

    Option Explicit
    
    Public Sub CommandButton1_Click()
        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
    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
    Austen, after this line ...

    Set Cel = .FindNext(Cel)
    .. you can use the Cel object as the cell to adjust. If your message box is trying to get the address, you need one before your Do/Loop and one after the above posted line. Is this what you mean?

    P.s. Please keep all threads related to one another together. This should have gone into the other thread (but it's ok ).

  3. #3
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    No the message box does not come up at all. Maybe I am missing something here...
    Peace of mind is found in some of the strangest places.

Posting Permissions

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