Share via

making a dynamic vlookup foformulae to query a key like 728 where each number in the value retrieves a different value from a data set

Tim Cox 40 Reputation points
2026-03-25T16:33:27.04+00:00

dear support,

i have a data set in excel as a list of events. for 1 specific day there could be many events for the day. i am trying to use excel 365 with vlookup to interogate a number and extract the value of left position 1, 2 and right , 1 i have managed to figure out the value to maintain the number which is hte value in the special events id field. i have mastered 2 vlook ups in hte same formulae concat usin &char(1)& and formatin the output sell to wrap text. my aim is to able to configure the number to look up as a dynamic feature thus allowing each day to have a defferant set of special events. i am doing this for a user say my grandmother so i dont want to have to reconfigure hte formulae every time thre is a change.

Microsoft 365 and Office | Excel | For home | Windows

3 answers

Sort by: Most helpful
  1. IlirU 2,176 Reputation points Volunteer Moderator
    2026-03-28T16:10:10.0266667+00:00

    User's image

    Hi @Tim Cox,

    If you are running Excel 365, then try the formula below. I have applied it to cell E2.

    =BYROW(D2:D9, LAMBDA(a, TEXTJOIN(CHAR(10),, IFNA(XLOOKUP(--REGEXEXTRACT(a, "\d", 1), A2:A11, IF(B2:B11 = "", "", B2:B11)), ""))))

    Hope this helps.

    IlirU

    0 comments No comments

  2. JeovanyCV 470 Reputation points Volunteer Moderator
    2026-03-28T04:18:29.5233333+00:00

    Hi Tim

    The following provides a solution based on the data you provided.

    For illustration purposes, in the picture below

    1. On the left, we have an Excel table named "sevents"
    2. I used cells G2 downwards to enter the event ID set of values
    3. In cell H2, enter the formula below and copy it down

    =TEXTJOIN(" - ",TRUE,IFERROR(VLOOKUP(VALUE(MID(G2,1,1)),sevents,2,FALSE),""),IFERROR(VLOOKUP(VALUE(MID(G2,2,1)),sevents,2,FALSE),""),IFERROR(VLOOKUP(VALUE(MID(G2,3,1)),sevents,2,FALSE),""))

    ** I used " - " as the event delimiter in the formula.

    ** Adapt the formula according to your scenario

    IMPORTANT NOTE:

    My concern with this table setup is that you are limited to at most 10 events in the table, using digits 0 to 9.

    If you enter more than 10, then you need to consider another way to enter the set of event IDs

    Forum-EventListing

    I hope this helps you and gives a solution to your problem.

    Do let me know if you need further help.

    Kind regards

    Jeovany CV

    0 comments No comments

  3. Barry Schwarz 5,431 Reputation points
    2026-03-27T23:49:35.49+00:00

    While left and right will allow you to extract the 1st and 3rd digits, you need to use mid(x,2,1) to extract the middle digit. From an ease of program maintenance point of view, it also makes sense to use mid for all 3 digits.

    If your data is in A1:B9 and your dynamic criteria is in F1, then this formula will do what you describe:

    Visual Basic for Applications

    =LET(data,A1:B9,look,LAMBDA(digit,VLOOKUP(VALUE(MID(F1,digit,1)),data,2)),look(1)&CHAR(10)&look(2)&CHAR(10)&look(3))
    

    The cell containing the formula needs to be wide enough to hold the longest string in column B, tall enough for three lines, and have the Wrap text format checked


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.