+ Reply to Thread
Results 1 to 3 of 3

create search box

  1. #1
    Registered User
    Join Date
    05-06-2011
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    1

    create search box

    hi,
    i am doing an phone book on excel ....and i need a macro that search for the cells that contains a name..but the problem is i don't want it to be accurate....i need to type part of the name and it finds me all cells that contain that part

    A1 A2 A3
    1 name phone
    2
    3

    here is a function i already had...but the problem is that its too accurate
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Search4 As Range, Found As Range
    '
    Set Search4 = Range("A4")
    '
    On Error Resume Next
    If Target(1, 1).Address = Search4.Address Then
    Set Found = Cells.Find( _
    What:=Search4, _
    After:=Search4, _
    LookIn:=xlValues, _
    LookAt:=xlWhole, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False, _
    SearchFormat:=False)
    If Found.Address = Search4.Address Then
    MsgBox "No match found."
    Else
    Found.Select
    End If: End If
    End Sub

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: create search box

    hi, donjuan88, please read Forum rules carefully and add code tags to the posted code.

  3. #3
    Registered User
    Join Date
    05-05-2011
    Location
    Belgium
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: create search box

    Hola donjuan88,

    If I understood well, the name to be searched will be typed on cell A4, si seņor? If so, see the example below (the trick is by using the "*" as wildcard). Please notice that macro was considering the name to be searched is on cell B2, but you can easily change that by adjusting the target.row/target.column in the macro:

    Please Login or Register  to view this content.


    My table looks like this:


    A1 A2
    Seach for _______

    Nome Phone
    ABC 123
    DEF 456


    Try that and let us know in case of any issue

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1