Link to home
Start Free TrialLog in
Avatar of Matt Miller
Matt MillerFlag for United States of America

asked on

Referencing Another Tab Based on a Cell Value

Hi I've inherited a spreadsheet with multiple tabs.   I am trying to break out the individual columns to individual tabs and then tie it into a backend.  I have the macro established to break it out into the individual tabs but am stumped on how to tie the backend into the individual tabs.  

I was wondering if there is a way to use a cell value to lead into the appropiate tab for a HLookup?

Thanks.
Avatar of Harry Lee
Harry Lee
Flag of Canada image

It really depends on what cell value you are referring to.

With If statement, and nested If statements, you can for sure do some sort of selection between which tab is used for the HLookup.

That also said, for sure you can do it in VBA.

What's the rule on which tab to use as the cell value change?
Avatar of NBVC
You can refer to a tab indirectly through a cell value using the INDIRECT() function

e.g. if you have a sheet named, MySheet, and you have a cell in the activesheet with text string in it as MySheet,  then you can reference that as =INDIRECT("'"&A1&"'!A1:A100)

this will refer to sheet shown in cell A1 and look at range A1:A100 in that sheet.
Avatar of Matt Miller

ASKER

I think I'm partway there but I'm getting a reference error.

=HLOOKUP(E1,INDIRECT("'"&E2) & "!$B$1:$AZ$1000",2,0)
ASKER CERTIFIED SOLUTION
Avatar of NBVC
NBVC
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much.  This is exactly what I needed.