Results 1 to 3 of 3

Thread: search with vba

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    151

    search with vba

    hi im not sure if this goes in this section but here goes

    i have done some code to search an excel document using a userform but ive run accross a small problem, the problem being when i click the search button it finds what i require but i would like it to display the contents of the whole row instead of just the item i searched for i have posted my code below if you can help i would be greatful.

    VB Code:
    1. If OptionButton1.Value = True Then
    2. With Worksheets(1).Range("A3:E65536")
    3.     Set c = .Find(TextBox1.Text, LookIn:=xlValues)
    4.     If Not c Is Nothing Then
    5.     firstAddress = c.Address
    6.        
    7.         MsgBox "This Staff Number Belongs To:", vbOKOnly, "Staff Number Found"
    8.        
    9.     Else
    10.         MsgBox "No Such Staff Number", vbOKOnly, "Staff Number Not Found"
    11.     End If
    12. End With
    13. End If

  2. #2
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: search with vba

    Try something like this:

    VB Code:
    1. For iCount = 1 To 5
    2.         sOut = sOut & c.Cells(1, iCount).Value & ","
    3.     Next iCount

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: search with vba

    Moved to Office Development.

Posting Permissions

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



Click Here to Expand Forum to Full Width