+ Reply to Thread
Results 1 to 5 of 5

Search and Cycle Through Matched (UserForm)

  1. #1
    Registered User
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    20

    Search and Cycle Through Matched (UserForm)

    Hi, I am writing to request help in cycling through matched findings on a userform.

    Several weeks ago, AlphaFrog kindly helped me in developing a code that helped me search an item through matched items in this forum. I have attached the workable code here.

    I am now wanting to cycle through found items, where if there are more than 1 match found. I'm struggling to do this, any help would be appreciated.

    Basically, the user has to input "unique ID" (Column C) and "date" (Column E). This should then return matched "Product Options" (column F), "Name of Company" (Column D) and "Price" (column I). The current code returns the first match. I would like the code to be expanded, so when I keep pressing "Search" on the userform, it will go to the next match, and so on.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Search and Cycle Through Matched (UserForm)

    I haven't thoroughly tested it, but I think I have something that might work. I basically took AlphaFrog's code and created a collection of matches for each search. This collection can be cycled through using a new "Next Match" button. Using the "Search" button for both conducting new searches and cycling through old searches can get needlessly messy, since you're asking one button to do two very different things. It seems to be working for me on the sample, but take a look at the attachment to see if it'll do the trick for you.
    If your problem has been solved, please use "Thread Tools" to mark the thread as "Solved".

    If you're grateful for this site's existence and would like to contribute to the community, please consider posting something hilarious in our joke thread:
    https://www.excelforum.com/the-water...ke-thread.html

  3. #3
    Registered User
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Search and Cycle Through Matched (UserForm)

    Hi, thanks for your response. I have tried to run it, but its not working, it comes with error. Firstly, when I put the unique ID and Date, next to Name of Product, it says "Showing 0 of 0 Matches".
    Capture1.PNG


    When I click on Next Match, it comes with error message "Run time Error '5' - Invalid Procedure call or Argument", points to Me.Company = ActiveSheet.Range("C4").Offset(iMatch(MatchNum) - 1, 1).value

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Search and Cycle Through Matched (UserForm)

    Odd.

    The "Next Match" issue you ran into isn't really a problem - if there are no matches, then there is no next match. I just neglected to include an error handler. The version attached to this post fixes that and better address a few other possible errors. That was just an oversight - apologies!

    The first issue, though, in which no matches are returned, is concerning because it works for me, so I can't replicate what you're seeing. Maybe it's a version issue? When you enter an ID that doesn't have a match in the table (e.g. b234), do you get a "No match found" pop-up, as you should? Or does the issue occur with both bad and good IDs?

    givemeaccessexcel.PNG
    Last edited by CAntosh; 07-20-2018 at 11:04 AM.

  5. #5
    Registered User
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Search and Cycle Through Matched (UserForm)

    It is working now. Thank you, this works brilliantly!

+ 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] Cycle through objects in userform with for loop
    By mason0567 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-16-2015, 06:31 PM
  2. Automate count of matched keywords by search
    By GregorySB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2015, 05:57 PM
  3. [SOLVED] Search for a partial string match and cycle through matching results
    By kamelkid2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2013, 08:27 AM
  4. Search a range and copy data if matched
    By Steven811 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-14-2012, 10:22 AM
  5. Help with a userform to enter data into cells in a matched row
    By luke8182 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-12-2012, 12:43 AM
  6. Using a Scrollbar to cycle pictures on a single UserForm
    By MadCrammer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2011, 05:42 PM
  7. Cycle through images on UserForm
    By cdb in forum Excel General
    Replies: 2
    Last Post: 01-27-2005, 09:06 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