+ Reply to Thread
Results 1 to 3 of 3

VBA to filter a table using a TextBox

  1. #1
    Forum Contributor
    Join Date
    06-25-2012
    Location
    U.K
    MS-Off Ver
    Excel 2016
    Posts
    101

    VBA to filter a table using a TextBox

    Hi,
    I am trying to use a TextBox to filter a table column.
    The code below is working fine on a column that just contains text, however i also have a column who's cells contain a formula that returns the value so the filter doesn't work because the cell has a formula in it not a value. Any ideas. Here is the code i am using.

    Please Login or Register  to view this content.
    Here is the Table

    Capture.JPG
    Last edited by randall78; 01-25-2019 at 03:57 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to filter a table using a TextBox

    What TextBox?
    J3 seems like a cell reference.

    You are using the * wildcard in the autofilter criteria which works on a column of text and not numbers. So for example if the filtered column is numbers, you cannot filter for a number that contains the digits 25. You could filter for greater than or less than 25 but not contains the digits 25.

    A workaround could be to have another column that converts the numeric data to text using the TEXT() function. Then you could filter that text column for entries that contain the two digits 25.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    06-29-2011
    Location
    Fort Lauderdale
    MS-Off Ver
    Excel 2018
    Posts
    24

    Re: VBA to filter a table using a TextBox

    I suspect you need to select a Range, for my examples I'm using columns A through Z, you could specify whatever you need.

    I created a table with text and numbers, and I filtered on 12 and 56, and it filtered them both for column A (field 1):
    Please Login or Register  to view this content.
    I also removed the equal signs within the search criteria and the code worked again just fine:

    Please Login or Register  to view this content.
    If you are searching for just a single filter then this works:
    Please Login or Register  to view this content.

+ 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. [SOLVED] Want to filter multiple string using comma with textbox as i filter
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2017, 09:29 AM
  2. When i do un filter a table then don't remove then filter icons from table
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-07-2017, 12:08 PM
  3. [SOLVED] How to filter a table using textbox and show filtered data in listbox (userform)
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-01-2017, 10:31 AM
  4. Want to add one more critieria to filter table suing textbox
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-17-2017, 11:34 AM
  5. Filter table with the help of textbox
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-06-2017, 09:50 AM
  6. Replies: 1
    Last Post: 04-07-2012, 04:36 PM
  7. Filter and add to textbox
    By bgf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-02-2008, 02:15 AM

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