+ Reply to Thread
Results 1 to 3 of 3

Search Box

Hybrid View

  1. #1
    Registered User
    Join Date
    08-08-2023
    Location
    India
    MS-Off Ver
    Ms Office 16
    Posts
    17

    Exclamation Search Box

    Dear All,

    I created a search box where in the data of a column gets filtered

    used the following code which worked initially but once the data was formatted to a table it stopped working, could someone guide which part of the code needs changing?


    the code is below-

    Dim SH As Worksheet
    Set SH = ThisWorkbook.Sheets("CUSTOMER_DATABASE")
    
    Dim LR As Integer
    LR = Application.WorksheetFunction.CountA(SH.Range("A:A"))
    
    If LR = 1 Then LR = 2
    
    
    Dim CUSTOMER_DISPLAY As Worksheet
    Set CUSTOMER_DISPLAY = ThisWorkbook.Sheets("CUSTOMER_DISPLAY")
    CUSTOMER_DISPLAY.Cells.Clear
    
    If Me.SEARCH_CD.Value <> "" Then
        SH.UsedRange.AutoFilter 2, "*" & Me.SEARCH_CD.Value & "*"
    End If
    SH.UsedRange.Copy CUSTOMER_DISPLAY.Range("A1")
    SH.AutoFilterMode = False
    Last edited by AliGW; 08-19-2023 at 11:47 AM. Reason: Code tags added - please review the forum rules.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,324

    Re: Search Box

    Please review the forum rules on code tags.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Search Box


    Hi,

    with a table start to activate the Macro Recorder and filter manually in order to see in the generated code what is specific to a table …

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Search partial text and return all rows of data that include search criteria
    By clintgebert in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-30-2023, 08:31 PM
  2. [SOLVED] Search multiple worksheets for search term and paste results in a summary sheet
    By Andy15 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 04-03-2017, 01:49 PM
  3. [SOLVED] Code to search Excel and return results even if part of search text is present
    By Taoyuan00 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2016, 09:20 AM
  4. Replies: 4
    Last Post: 12-02-2014, 05:17 PM
  5. Replies: 4
    Last Post: 11-08-2014, 04:57 AM
  6. VBA Code - Search text & search number & search qty and result - Urgent Please
    By naresh73 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2014, 10:51 AM
  7. Replies: 1
    Last Post: 10-18-2012, 05:52 AM

Tags for this Thread

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