+ Reply to Thread
Results 1 to 10 of 10

vba find next search value based on input box

  1. #1
    Registered User
    Join Date
    02-16-2018
    Location
    Lagos
    MS-Off Ver
    MS Office 2016
    Posts
    25

    vba find next search value based on input box

    Hello Fam,

    I have a workbook containing a worksheet with a list of details and I have managed to put together a VB code shown below that finds the first match for the input box value but I need it to give 'next' option on the message box with the result to find the next match if there is one. For instance, if the word "index" occurs 3 times I'd like to be able to click next for it to go to the next match for the word "index". The search range is on column B on worksheet "Main" in the attached file (Dashboard X)

    Please help!


    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: vba find next search value based on input box

    Instead of using WorksheetFunction to find match. Try using Range.Find method.

    Something like below...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    02-16-2018
    Location
    Lagos
    MS-Off Ver
    MS Office 2016
    Posts
    25

    Re: vba find next search value based on input box

    Thanks a bunch CK76.. but using range.find looks for an exact match but I want the code to search for any word/string with the input provided. for instance, If I input the word "index" I want it to display details for 'account index' followed by 'fee index' and so on, if applicable hence the use of worksheet-function 'index' and 'match' as shown below:

    Please Login or Register  to view this content.
    If there's a shorter line of code I won't mind..

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: vba find next search value based on input box

    Did you actually run the code or use the workbook I uploaded?

    Range.Find() without argument for "LookAt:=" parameter, will default to xlPart.
    Meaning it will find partial match (i.e. if you use "index" it will show detail for "Account Index", and then "Fee Index").

    Try it on the workbook I uploaded.
    Last edited by CK76; 08-09-2018 at 11:38 AM.

  5. #5
    Registered User
    Join Date
    02-16-2018
    Location
    Lagos
    MS-Off Ver
    MS Office 2016
    Posts
    25

    Re: vba find next search value based on input box

    Yes I ran the code you uploaded and using "index" shows 'Solution Not Present in the table'

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: vba find next search value based on input box

    ? It shows following on my end.

    With "index" without quotes in inputbox...
    0.JPG

    Next is...
    1.JPG

    Try adding the parameter "LookAt:="
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: vba find next search value based on input box

    From Ozgrid 49668:
    The settings LookIn, LookAt and SearchOrder are saved each time the Find Method is used.
    For this reason one should always specify these settings explicitly each and every time you use the Find Method.
    If you don't, you run the risk of using the Find Method with settings you were not aware of.

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: vba find next search value based on input box

    Ah, good to know. I've never used anything other than partial match and had never encountered that issue.

    Thanks for the heads up

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: vba find next search value based on input box

    We seem to learn all these things through trial and error.

  10. #10
    Registered User
    Join Date
    02-16-2018
    Location
    Lagos
    MS-Off Ver
    MS Office 2016
    Posts
    25

    Re: vba find next search value based on input box

    Wow! Nice work CK76.. you really got me through this! Thanks for the tip as well jolivanes. appreciate y'all!

+ 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/Find/Jump To cell based on multiple string input
    By flinty82 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-22-2016, 09:00 AM
  2. [SOLVED] Search Best Match based on Criteria input
    By ieyfan in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-18-2016, 02:06 AM
  3. Search within range and input data based off a radio button
    By dizzle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2014, 03:15 PM
  4. help. Search based on text input in a column selects a row and copies data.
    By ridermarangoni in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-27-2012, 10:53 AM
  5. [SOLVED] Macro to search through dates and display results based on user input
    By Alan668 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-22-2012, 12:40 PM
  6. Fast search and delete based on input criteria
    By shinichi_nguyen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-29-2012, 01:32 PM
  7. [SOLVED] Find and input value based on month
    By Django in forum Excel General
    Replies: 2
    Last Post: 03-02-2006, 05:20 PM

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