Lookup where target worksheet may vary

N

Nigel Barton

I have a formula, similar to one below, that I want to use in many workbooks:

=HLOOKUP(TCI_TestCycle,[TestGroups.xls]REGR!Group,5,FALSE)

The worksheet REGR however will change. Sometimes it will have other values
depending on the workbook in which the formula is used. These worksheets are
in a separate workbook.

How, instead of the string REGR, can I insert a value from another cell in
the workbook?

Thanks,
 
S

Sam Wilson

If A1 contained "REGR" or another sheetname:

=HLOOKUP(TCI_TestCycle,INDIRECT("[TestGroups.xls]" & A1 & "!Group"),5,FALSE)
 
D

Dave Peterson

Sometimes you'll need to surround the workbook/worksheet name with apostrophes:

=HLOOKUP(TCI_TestCycle,indirect("'[TestGroups.xls]" & a1 & "'!Group"),5,FALSE)

And =indirect() will only work if the sending workbook is open.

Saved from a previous post.

The function you'd want to use that's built into excel is =indirect(). But that
function returns an error if the sending workbook is closed.

If that's a problem, then Laurent Longre has an addin (morefunc.xll) at:
http://xcell05.free.fr/
or
http://xcell05.free.fr/morefunc/english/index.htm

That includes =indirect.ext() that may help you.


Nigel said:
I have a formula, similar to one below, that I want to use in many workbooks:

=HLOOKUP(TCI_TestCycle,[TestGroups.xls]REGR!Group,5,FALSE)

The worksheet REGR however will change. Sometimes it will have other values
depending on the workbook in which the formula is used. These worksheets are
in a separate workbook.

How, instead of the string REGR, can I insert a value from another cell in
the workbook?

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top