+ Reply to Thread
Results 1 to 9 of 9

How to make "_ " = "Space" when searching value in Excel with VBA

  1. #1
    Registered User
    Join Date
    09-21-2023
    Location
    hcm
    MS-Off Ver
    2020
    Posts
    4

    How to make "_ " = "Space" when searching value in Excel with VBA

    I have a table like this.
    jghAG.png

    And after I search "abc_d" in "B5" it will show up like this
    zqPPL.png

    I want every time I search for "abc d" in the "B5". It will also understand that I'm looking for "abc_d".

    This is my code in VBA for searching value by filtering column

    Please Login or Register  to view this content.

    Thank you
    Last edited by khoavutrantrieu17; 09-21-2023 at 01:14 PM.

  2. #2
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: How to make "_ " = "Space" when searching value in Excel with VBA

    Hi, try this

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: How to make "_ " = "Space" when searching value in Excel with VBA

    I want every time I search for "abc d" in the "B5".
    If you click the autofilter arrow in B6, the value "abc d" will not appear as an option to select because it does not exist in column B. So why would you want to search for "abc d" if it doesn't exist in column B?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Registered User
    Join Date
    09-21-2023
    Location
    hcm
    MS-Off Ver
    2020
    Posts
    4

    Re: How to make "_ " = "Space" when searching value in Excel with VBA

    It worked. but this table is just an example. But when i change abc_d to abc_d efg with a space between d and e it will not worked. So is there any solution to this problem ? Thank you

  5. #5
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: How to make "_ " = "Space" when searching value in Excel with VBA

    So your example is not complete, place a relevant sample file pls

  6. #6
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: How to make "_ " = "Space" when searching value in Excel with VBA

    Does this work for you?

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-21-2023
    Location
    hcm
    MS-Off Ver
    2020
    Posts
    4

    Re: How to make "_ " = "Space" when searching value in Excel with VBA

    Book1.xlsx
    This is the complete example. And this is for:
    _ Search data in Column A and B by Filtering with the code i upload on the top (Finish)
    _ Whenever i search data in Column B. I want to make excel know that "space" when I search in "B5" equal to "_" in column B (exp: when i search "Apple Company ltd" in "B5" it also show every "Apple_Company ltd" value")

    Thank you

  8. #8
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: How to make "_ " = "Space" when searching value in Excel with VBA

    You might be better off using the Worksheet_Change event rather than Selection_Change

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-21-2023
    Location
    hcm
    MS-Off Ver
    2020
    Posts
    4

    Re: How to make "_ " = "Space" when searching value in Excel with VBA

    It worked. Thank u very much
    Attached Images Attached Images
    Last edited by khoavutrantrieu17; 09-21-2023 at 01:13 PM.

+ 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] Searching text for "X" OR "Y" OR "Z" and returning true or false
    By cjcreamer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-28-2021, 02:09 PM
  2. Replies: 5
    Last Post: 02-05-2019, 12:03 AM
  3. [SOLVED] Excel 2010 -- "Visual Basic" "Macros" and "Record Macro" all disabled.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2017, 06:11 AM
  4. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  5. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  6. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  7. [SOLVED] If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ...
    By Maria J-son in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2006, 08:25 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