+ Reply to Thread
Results 1 to 3 of 3

Macro to select next result that an xlookup would return

  1. #1
    Registered User
    Join Date
    06-17-2021
    Location
    Washington, USA
    MS-Off Ver
    Current
    Posts
    19

    Macro to select next result that an xlookup would return

    I am creating a UserForm that is pulling records of my customers from a worksheet to my UserForm using this code:

    Please Login or Register  to view this content.
    The data is then populating this form:

    Screenshot 20SFDFSDFSE23-04-18 101459.png

    This is fine, but my customers that I am looking up have multiple records, and I want a function that selects the next record down that falls into the XLookup criteria.

    TLDR, i want to press a button that shows the next thing down a list that my xlookup would be returning.
    Last edited by Dylan1023; 04-18-2023 at 05:25 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,326

    Re: Macro to select next result that an xlookup would return

    Quote Originally Posted by Dylan1023 View Post
    I want a function that selects the next record down that falls into the XLookup criteria.
    I am not clear on what you mean by this. Do you mean that searching for SalesForm.BHSDMAINNUMBERLF.Value there is more than one match in Range("E:E") and you want to return the second match instead of the first?

    If so, your code must be entirely rewritten. I would use the Find method to find the first, then FindNext to find the second. I would do this by having factoring out this functionality into one Sub that your others subs would call. For example:
    Please Login or Register  to view this content.
    Untested because file not provided.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Macro to select next result that an xlookup would return

    Hello.
    It seems to me that you are "complicating life" unnecessarily.

    I suggest you upload a short workbook (no more than 10 records) and your macros to the Forum so we can show you better ways to manage your information.
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

+ 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. Xlookup make result blank if contains keyword
    By LocSpreader in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-01-2023, 03:57 AM
  2. [SOLVED] trying to use xlookup to get the result of looking at 2 columns
    By gjjh25 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-30-2022, 08:19 AM
  3. [SOLVED] Query on using XLOOKUP to return a value just once
    By Majestic1976 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-09-2021, 11:33 AM
  4. Xlookup return maximum value
    By tommackie in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-09-2021, 04:10 AM
  5. using xlookup to select last non-null value
    By veloluz in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-28-2021, 10:40 AM
  6. Replies: 1
    Last Post: 02-12-2013, 06:02 PM
  7. Macro to select the result of an autofilter action
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2005, 07:15 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