Using indirect function in an IF statement with quotes - excel

I'm making multiple IF statements that are going to have the same layout. Instead of writing the reference sheet name I'd like to reference a cell for the sheet name.
Also in the interests of laziness I'd like to drag the formula so it changes locations it is looking at on the referenced sheet.
At the moment it looks like this.
=IF(sheet1!O2="","",sheet1!O2)
Simple enough.
However I want to use indirect and I can't write it without getting an error.
Last attempt was
=IF((indirect($B$3))!O2="","",(indirect($B$3))!O2)
where Sheet1 is in the cell B3
Doesn't work.
Any help on the correct syntax would be very appreciated.

You need to concatenate $B$3 and "!O2" to generate "Sheet1!O2" as a string for INDIRECT to work, as below:
=IF(indirect($B$3&"!O2")="","",indirect($B$3&"!O2")

Related

Finding a range and then implementing it in another formula

I am trying to use a variable range based on a pre-defined criteria. In my case I would like to find the range of the “AUD” cells in the table. I managed to get the beginning of the range thanks to:
=ADDRESS(1;MATCH("AUD";1:1;0))
And then I found the end of the range using a slightly modified above formula:
=ADDRESS(1;(MATCH("AUD";1:1;0)+(COUNTIF(1:1;"AUD"))-1))
Then I simply combined the results with the following formula:
=(B4&":"&C4)
And the achieved result was:
$B$1:$D$1
However, I am having difficulties implementing this result inside formulas in which range must be defined, which brings me to my following questions:
Is such kind of implementation possible in EXCEL, I suspect that the result is considered as a simple text and not actually a cell reference? Is there a way I can change that?
One step further, if we trim (for example from $B$1 to just $B) can we still make the formula working?
Due to the fact that to save space I will probably write all the above formulas inside one formula and I expect this formula to become huge, would it be possible to create a VBA public function which can store the range in a variable and then just refer this variable to the formula - for example, SUMIF("=audRefCell()";"AUD";2:2).
I would like to thank you in advance for the help!

Excel "INDIRECT" function with parameter from "CONCATENATE"

I am using an INDIRECT function to get value of a cell (B4) for many sheets in my workbook.
At the moment I have to hard code the name of the sheets like this
=INDIRECT("WCNEXP!$B$4")
Ideally I would like to find a way to compile the name "WCNEXP" with the help of the CONCATENATE formula, like this
=INDIRECT("CONCATENATE(B18,C18)!$B$4")
but it does not work for some reason.
Is there another way to get the name compiled from 2 cells and use the INDIRECT Formula ?
Photo of the workbook
Your code is almost good.
the quotes must be placed after the concatenate function, and with the use of "&" to join them.
=INDIRECT(CONCATENATE(B18,C18)&"!$B$4")

Inserting an INDIRECT into another formula to replace fixed values

I'm trying to do the following.
Take a value in a defined cell
Look up that value on another sheet called 'Updates'.
Look across the row for the last non-empty cell
Look up from there and return the header.
I know that if there was a defined range, the following formula works great for the last two steps.
=LOOKUP(2,1/(Updates!B3:E3<>0),Updates!B2:E2)
However I tried to make it more flexible with INDIRECT and came up with the abomination of a formula which I intended to just copy down.
=LOOKUP(2,1/INDIRECT("Updates!B"&B5+2&":S"&B5+2<>0),Updates!$B$2:$S$2)
However this just returns a #REF error. Is this type of thing not possible or is there a simpler way to go about it?
Thanks
I think you're not closing the INDIRECT statement before making the <>0 test - so move that bracket to the left and it should work; ie
= LOOKUP(2,1/INDIRECT("Updates!B"&B5+2&":S"&B5+2) <>0, Updates!$B$2:$S$2)

Why does INDIRECT() not work with name references?

As far as my understanding goes, if you have value 5 in H4, there are two ways to reference that cell that both work:
=H4
and
=INDIRECT("H4")
I can't figure out a way to make this work with name references though. For example, if I have some data I'd like to calculate the sum of, I can do this:
=SUM(Main!SomeData)
but the other method...
=SUM(INDIRECT("Main!SomeData"))
suddenly does NOT work, and I get a #REF error. I need to be able to use a named range in my INDIRECT() for something more complex, but I can't wrap my head around why it won't work like this. Can anyone help?
Your formula will work if Main is the name of the workbook (not the worksheet) in which the formula resides:
If the formula resides in a different workbook, (say Book1.xlsx), then both should be open for the formula to work.

How do I use the result of one function in another function to get the value stored in a cell in another sheet in Excel?

In my current sheet I have some numbers in a column, which represent the row which I want to get the data from in another sheet. And I want to get it from the same column in which I am using the function...
I know using =Sheet1!A1 for instance gets me what is in A1 on Sheet1
and
=CONCATENATE("A",A1) being on sheet two, brings me back A + whatever value is stored in A1 on sheet number two... for simplicity let's say it's a one... so it would return A1
I am on Sheet2
I'm trying
=Sheet1!CONCATENATE("A", A1)
but the formula contains an error, I've tried rewriting this in many ways but it never works... any idea what the correct syntax I need is?
Greatly appreciated!
THanks
As Magicianeer said, you have to use the INDIRECT function. For your example:
=INDIRECT(CONCATENATE("Sheet1!","A",A1))
Should give the results you need.
However, it's a bit lengthy, and you can use & instead of CONCATENATE, and you can directly use Sheet1!A:
=INDIRECT("Sheet1!A"&A1)
What is evaluated in the brackets is Sheet1!A1, and INDIRECT converts this from text to a reference.
Try:
=CONCATENATE("A", Sheet1!A1)

Resources