Generating a cell reference within a formula

T

Todd S

How do you generate a reference to a cell in another worksheet based on the
contents of a cell in the current worksheet.

Here is what I have been trying. Logically it works. But when true, it
returns the text that I am concatenating rather then the value of the cell
that I am referencing.

Cell A6 = January, 2008

=IF(CONCATENATE("'"&A6&"'!B2")<>0,CONCATENATE("'"&A6&"'!B2"),"")
 
T

Tom Hutchins

Use the INDIRECT function to make Excel treat the concatenated text as an
address:

=IF(CONCATENATE("'"&A6&"'!B2")<>0,INDIRECT(CONCATENATE("'"&A6&"'!B2")),"")

Hope this helps,

Hutch
 
T

Todd S

Thanks Tom, that worked well! However, now when the result is false, it
returns "0.00" rather than "". Suggestions?
 
T

Tom Hutchins

Use the INDIRECT function twice:

=IF(INDIRECT(CONCATENATE("'"&A6&"'!B2"))<>0,INDIRECT(CONCATENATE("'"&A6&"'!B2")),"")

Hutch
 
T

Todd S

Thanks Tom. Works perfectly!

Tom Hutchins said:
Use the INDIRECT function twice:

=IF(INDIRECT(CONCATENATE("'"&A6&"'!B2"))<>0,INDIRECT(CONCATENATE("'"&A6&"'!B2")),"")

Hutch
 
D

Dave Peterson

The =concatenate() function serves the same purpose as the & operator. But you
don't need both:

=IF(INDIRECT("'"&A6&"'!B2")<>0,INDIRECT("'"&A6&"'!B2"),"")
or
=IF(INDIRECT(CONCATENATE("'",A6,"'!B2"))<>0,
INDIRECT(CONCATENATE("'",A6,"'!B2")),"")

(two lines to avoid line wrap in the post.)
 

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