Change range on VLOOKUP

imimin

Active Member
Joined
May 9, 2006
Messages
404
Hello!

How could I change the following VLOOKUP to set the range so it will stop on the last row that has data (instead of using the range $A$2:$A$10000) AND so it will auto populate that range? Is that EVEN possible? I guess that would be a macro?


Code:
=IF(COUNTIF(Sheet2!$A$2:$A$10000,A2),VLOOKUP(A2,Sheet2!$A$2:$B$10000,2,FALSE),"")

Thanks for the help!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hello!

How could I change the following VLOOKUP to set the range so it will stop on the last row that has data (instead of using the range $A$2:$A$10000) AND so it will auto populate that range? Is that EVEN possible? I guess that would be a macro?


Code:
=IF(COUNTIF(Sheet2!$A$2:$A$10000,A2),VLOOKUP(A2,Sheet2!$A$2:$B$10000,2,FALSE),"")

Thanks for the help!

If the range in column A consists of text...

A1:
Code:
=MATCH(REPT("z",255),Sheet2!A:A)

If the range in column A is numeric...

A1:
Code:
=MATCH(9.99999999999999E+307,Sheet2!A:A)

Now you can invoke:
Code:
=IF(ISNUMBER(MATCH(A2,Sheet2!$A$2:INDEX(Sheet2!A:A,$A$1),0)),
      VLOOKUP(A2,Sheet2!$A$2:INDEX(Sheet2!B:B,$A$1),2,0),"")
 
Upvote 0

Forum statistics

Threads
1,224,565
Messages
6,179,549
Members
452,927
Latest member
rows and columns

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top