Dynamic INDIRECT formula with range - excel

I have some dynamic input, in my case, the name of the month in cell I25. Based on the month the function in cell H32 should reference a sheet with the name of the month and cell A18 within that sheet. Now this I can handle and have made it possible through the INDIRECT function.
The issue I'm having is with dynamic range. For example, I would like cell H33 to reference cell A19 within the worksheet "February". The closest I got to it was =INDIRECT($I$25"&"!A18:A200"). And it seems to be working, but for some strange reason it starts referencing the cells contents from A36 onwards, which I don't get. Suggestions?
Any help would be greatly appreciated.

Use this one in H32 and drag it down:
=INDIRECT("'" & $I$25 & "'!" & CELL("address",A18))
Notes:
I've changed $I$25 & "!" to "'" & $I$25 & "'!" in formula to make it more reliable (for the case when sheet name contains spaces you should include your sheet name in single quotes like this: 'My sheet'!A18)
In H32 this formula evaluates to =Feb!A18 (where Feb is your sheet name), in H33 to =Feb!A19 and so on.

Related

get the value of a cell in a different worksheet by referring the name of the worksheet contains in some other cell

I want to get the value of a cell in a different worksheet by referring the name of the worksheet contains in some other cell.
For an instance, I have this formula to get the value from a cell from another sheet ='Sheet2'!H25. But I want to replace the 'Sheet2' of the formula of a cell contains the text "sheet2".
Cell A25 contains the name of a sheet titled "Sheet2" which I got from the formula =MID(CELL("filename", A1),FIND("]",CELL("filename", A1))+1,31)
So, instead of ='Sheet2'!H25 I tried the formula =INDIRECT("'" A25 & "'!" & H25) But it doesn't work. How to make it work.
P.S: A25 is in the Sheet1 and H25 is in the sheet2
You just forgot to double-quote H25 .
Either:
=INDIRECT("'" & A25 & "'" & "!" & "H25")
or
=INDIRECT("'" & A25& "'!H25")
(the second equation combines the various parts after the sheet-name)

Using INDIRECT inside HYPERLINK in excel

I am trying to create a hyperlink in Excel that references a cell on my worksheet, to get the sheet name.
Here is the working formula, with a static value.
=HYPERLINK("[\\xxxfs01\xxxxxxxx\IT\Monthly Reporting\Data\Computers Report for xxxDMZWSUS01.xls]Sheet1!A1","CLICK HERE")
When I use INDIRECT to reference a dynamic value, the cell just shows a value of #VALUE!
Here is what I have tried.
=HYPERLINK(INDIRECT("""&[\\xxxfs01\STS-Defence\IT\Monthly Reporting\Data\Computers Report for xxxDMZWSUS01.xls]"&[#Sheet]&"!A1&""","CLICK HERE"))
=HYPERLINK(INDIRECT(CHAR(34)&"[\\xxxfs01\STS-Defence\IT\Monthly Reporting\Data\Computers Report for xxxDMZWSUS01.xls]"&"Sheet1"&"!A1"&CHAR(34),"CLICK HERE"))
Can anyone help with the correct syntax?
You don't need INDIRECT to put together a Hyperlink location (INDIRECT is specifically intended to allow you to change the cell being reference in a formula, and that's not what I think you're trying to do). I'm listing steps below, because I think it might be a tiny bit confusing what you are trying to do, so this gives you a chance to see if I understood your problem correctly.
You are in Worksheet1.xlsx, Sheet1
In cell B2 of Sheet1, you want to enter the name of a worksheet from a different file: Computers Report for xxxDMZWSUS01.xls
In cell B3 of Sheet1, you have a hyperlink to go to cell A1 of the worksheet named in cell B2
The formula in B3 should be:
=HYPERLINK("[\\xxxfs01\xxxxxxxx\IT\Monthly Reporting\Data\Computers Report for xxxDMZWSUS01.xls]"&B2&"!A1","CLICK HERE")
INDIRECT Worksheet Function
Returns the reference specified by a text string. References are immediately evaluated to display their contents. Use INDIRECT when you want to change the reference to a cell within a formula without changing the formula itself.
An example of using INDIRECT and HYPERLINK is:
=IF(TRIM(A2)="","",IF(ISERROR(INDIRECT("'" & A2 & "'!$A$1")),"missing",
HYPERLINK("#" & "'" & A2 & "'!$A$1",INDIRECT("'" & A2 & "'!$B$2")) ))
Reference is http://dmcritchie.mvps.org/excel/indirect.htm

Reference sheet name via cell inside Excel formula

As you can see in the image or formula below, I am writing a series of formulas that are referencing the sheet "Lulu." Instead of rewriting "Lulu" over and over, I would like to write Lulu once in cell B1 and reference cell B1 inside the formula.
=AVERAGE(LULU!$C$4:$C$5)/AVERAGE(LULU!$D$4:$D$5)-1
Use INDIRECT(), but this will be longer:
=AVERAGE(INDIRECT("'" & B1 & "'!$C$4:$C$5"))/AVERAGE(INDIRECT("'" & B1 & "'!$D$4:$D$5"))-1

Get Range From A Separate Sheet Using a Variable in Excel

Looking to get a range from another sheet based upon the Column Letter which is obtained from the current sheet.
So say that I designate A2 on the current sheet to the letter G.
I would then ask A10 to =AVERAGE('Sheet1'!(A2)2:(A2)999)
So essentially it would be =AVERAGE('Sheet1'!G2:G999)
However, this doesn't work. Anyone have any idea how to make this worK?
You would use the Indirect() function:
=AVERAGE(INDIRECT("'Sheet1'!" & A2 & "2:" & A2 & "999"))

How to make a reference to a cell of another sheet, when the sheet name is the value of a cell?

In excel 2007, I have a formula in a cell like the following:
=COUNTIFS('2008-10-31'!$C:$C;">="&'$A7)
Now I want to make the name of the sheet ('2008-10-31') be dependent on the value of some cell (say A1). Something like:
=COUNTIFS(A1!$C:$C;">="&'$A7) // error
Is there is way to do this? Or do I have to write a VBA-Macro for it?
INDIRECT does what you want. Note that if the sheet name has any spaces, you need to put single quotes round it, ie
=COUNTIFS(INDIRECT("'" & A1 & "'!$C:$C"); ">=" & $A7)
You are looking for the INDIRECT worksheet function:
=INDIRECT("SHEET2!A1")
=COUNTIFS(INDIRECT(A1 & "!$C:$C"); ">=" & $A7)
The function turns a string into a real cell reference.

Resources