Suppose I have a bunch of sheets, named uninterestingly Main and then ModelA, ModelB, ... In Main, I just want to aggregate the models on these various sheets.
How can I structure it so that if cell A1 contains the name of a sheet (e.g. ModelA) then cell B1 contains the value of C14 in the cell in the sheet referenced by A1. (Explicitly, this would be ='ModelA'!C14, but I don't want to be explicit).
So you will have the Sheet name in column A and want to see whatever sheet that is, but cell C14's value?
=INDIRECT("'"&A1&"'!C14")
Actually, I think this is what you want based on your question:
=INDIRECT("'" & A1 & "'!" & B1)
Related
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
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
I have a submission form, Sheet1, and a datasheet that does calculations, Sheet2. Sheet2 contains a list of Names and Dates and empty cells ready to be filled.
On Sheet1, the user selects a Name from a list in A2 (using data validation, with the source being a 3rd reference sheet), then enters values in C1, D1, E1, F1, etc. The user then clicks a button that prints the form sheet, Sheet1.
I also want to also transfer the data from C1, D1, E1 etc into Sheet2, and slot them into the correct row, which is which ever row has the corresponding Name entered in Sheet1!B1 in Sheet2!A1.
I'm comfortable with VBA copying defined cells to other defined cells, but am unsure of how to combine that with finding the correct position in Sheet2 based on the value in A. Below are Sheet1 and Sheet2.
Please modify to suit your requirement
Sub copyrange()
Dim sheet2_row As Integer
sheet1_name = Sheets("Sheet1").Cells(2, 2).Value
sheet2_row=WorksheetFunction.Match(sheet1_name,Sheets("Sheet2").Range("A1:A10"), 0)
Sheets("Sheet1").Range("C2:AG2").Copy
Sheets("Sheet2").Range("B" & sheet2_row & " : AF" & sheet2_row).PasteSpecial xlPasteValues
End Sub
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"))
I have a worksheet (let me call it WorksheetA) that each row has a different information. Then, I want to refer these information (per row) on my other worksheet (WorksheetB).
To explain further, WorksheetA has 2 columns that should be copied to WorksheetB. These are "Name" and "School Last Attended". I want to know how can WorksheetB be updated every time a new row in WorksheetA is filled. Also, there will only be one cell on WorksheetB to hold values for the column "Name" from WorksheetA and another one cell (WorksheetB) for column "School Last Attended" from WorksheetA.
It will be really helpful if the answer to this question is within the environment of Excel, that I won't have to require any other software/program.
Thanks in advance!! :)
OK I may may not have interpreted this correctly but here goes.
In Sheet1 (your Worksheet A) we have two columns of data which are updated by adding to the end of the list:
In Sheet2 (your Worksheet B) there are two cells (B4 and D4 in this example) that hold and will continually update with the LAST details held in the Sheet1 list.
To achieve this ON:
SHEET2 in cell B4 enter: =INDIRECT("'" & B1 & "'!B" & COUNTA(Sheet1!B:B))
SHEET2 in cell D4 enter: =OFFSET(INDIRECT("'" & B1 & "'!B" & COUNTA(Sheet1!B:B)),0,1)
Edit (in hindsight)
Note that you must include the name of the data worksheet in cell B1 of sheet2 - this is required for the INDIRECT function to operate across sheets.
Note also that there should be no blank rows in the block of data in Sheet1 - this is because the last data value in col B is being found using COUNTA