Search code examples
excelexcel-formulacell

Use cell X3 in function with lookup


Hey guys I have a bunch of strings in a column and I am getting the row number of the last string by using the following:

=MATCH(REPT("z",255),StaticData!G:G)

It gives me a number 256 and it is in cell X3.

I am using a lookup and I would like to specify this number in cell X3:

=IFERROR(VLOOKUP(A2,Sheet1!$C$4:$D$256,2,0),"")

Where the 260 is right now I would like to place X3 but it is giving me errors.

So like:

=IFERROR(VLOOKUP(A2,Sheet1!$C$4:$D$X3,2,0),"")

Anyone know how I can do this? Thanks!


Solution

  • You are looking for Offset:

    =IFERROR(VLOOKUP(A2,Sheet1!$C$4:OFFSET($D$1,$X$3-1,0),2,0),"")