I have a spreadsheet that contains one summary worksheet and over 300 detail worksheets. The summary page is used simply as a roll-up of key metrics.
What I need to do now is, using a separate sheet create a dynamic link to the data on the detail sheets, grabbing selected information for an appointment record.
I successfully resolve the worksheet name using VLOOKUP, and have that in a cell.
When I try to take that cell and create a reference to the detail worksheet, the formula doesn't resolve. No, it hasn't been changed to text.
Here's an example:
Customer # 535018 resolves correctly to 'Aberdeen Gardens'
This is the data that sits in cell C4.
In cell B6 I want Excel to use the data in C4 to construct and resolve the cell C5 on the Aberdeen Gardens worksheet.
I used the following: =" ' " & $c$4 & " '!$c$5" {spaces are for comprehension}
When I hit enter, what I see in the cell is 'Aberdeen Gardens'!$C$5 which is exactly correct to access the data I want to see. When I type this reference in without a formula, it resolves and does what I want.
What the heck have I not done right?
You'd want to use Indirect().
=Indirect("'" & $C$4 & "'!" & "$C$5") {I added spaces for comprehension}
Make sure your final reference (the one that's for the cell itself) is also in quotes. I forget sometimes and try =Indirect("'" & $C$4 & "'!" & $C$5) and get confused when it doesn't work. Add quotes!
Related
If I manually reference a cell in another spreadsheet (by typing = in the destination cell and then clicking in the source spreadsheet), excel creates a formula like this: ='H:\excel\data\[source_file.xls]Sheet1'!$C$5
I am wanting to create that formula from the cell and path which are stored in cells in the destination spreadsheet (and some strings).
So I have in 3 cells B1:B3 in the destination spreadsheet these strings:
H:\excel\data\
source_file.xls
Sheet1!$c$5
Then, so far, I have placed this formula in the cell where I want the data from the source spreadsheet:
=B1&"["&B2&"]"&B3
Which evaluates to:
H:\excel\data\[source_file.xls]Sheet1!$c$5
Pretty close to what I need. But as you can see some single quotes are missing. If I try to put these in, excel seems to think I am giving it a defined name.
Is there perhaps some sort of escape character I should put before the quote to make it work?
I have searched this website and excel help files to no avail.
That is the end of the question but I anticipate that someone is going to ask me why I am doing this. Well I want to automatically pluck values from a directory full of spreadsheets (which all have the same format)the value of one cell from each.
I had tried to do it using the advice found here:
http://www.ashishmathur.com/extract-data-from-multiple-cells-of-closed-excel-files/
Unfortunately, I was only able to get the first step to work (create a list of filenames of the files in the source directory). The remaining steps are not possible because my employer does not allow downloading of add-ins for security reasons (it is a hospital).
So I thought the approach outlines above might work but I can't quite make it happen!
Thanks
Mike A
Use INDIRECT()
=INDIRECT("'" & B1 & "[" & B2 & "]" & B3)
As stated in the comments the ' would need to added to B3, so the input is Sheet1'!$C$5.
You may want to split the sheet name from the cell address then you could do:
=INDIRECT("'" & B1 & "[" & B2 & "]" & B3 & "'!" & B4)
Where B3 is only the sheet name and B4 the cell address.
I want to use dynamic formulas...
I know that you can refer to a Sheet name in Excel using INDIRECT() with a value in the current sheet, e.g.
=INDIRECT("'" & INDIRECT("B" & ROW()) & "'! T32")
However, I want to refer to a sheet name using INDIRECT() within an INDEX MATCH Formula. The previous formula is not dynamic and can't be copied across all cells in a block.
The Manual version that works is:
=INDEX('Sheet1'!$T$33:$AE$33,MATCH(INDIRECT(ADDRESS(3,COLUMN())),'Sheet1'!$T$32:$AE$32,0))
I have tried various ways to include an INDIRECT() as above instead of using the actual sheet name but have had no luck so far... any suggestions? The problem may be coming from the fact that I am referring to a range of cells, but I a still not sure how to get around this...
An example of what I have tried:
=INDEX(INDIRECT("'" & INDIRECT("B", Row()) & "'!$T$33:$AE$33"),MATCH(INDIRECT(ADDRESS(3,COLUMN())),'Sheet1'!$T$32:$AE$32,0))
The error I get is a #REF! error...
Thanks in advance!
I am not really sure how to explain it, I am trying to run one formula to search for information and use the result multiple times in a single cell. I am currently doing this to display the queried value AND then running the same formula to find the average also.
Example Formula (Simplified)
=<FormulaToFindValue> & " (" & Round(<FormulaToFindValue>/I52,2) & "/day)"
Acutal Formula
=SUMPRODUCT((MONTH('W.A.R. 2016'!$A4:$A369)>=7)*(MONTH('W.A.R. 2016'!$A4:$A369)<=9)*('W.A.R. 2016'!$A4:$A369<TODAY())*('W.A.R. 2016'!Q4:Q369)) & " (~" & IFERROR(ROUND(SUMPRODUCT((MONTH('W.A.R. 2016'!$A4:$A369)>=7)*(MONTH('W.A.R. 2016'!$A4:$A369)<=9)*('W.A.R. 2016'!$A4:$A369<TODAY())*('W.A.R. 2016'!Q4:Q369))/B18,2),0) & "/day)"
As you can see I have to use the same Formula two times in the same cell to get the result I want, is there a way to only run the Formula once and use the resulting value multiple times? Usually this would be done by storing the value in a variable but I can't don't see similar capability in excel.
Put the formula in a name (be careful to pick your relevant choice between fixed and dynamic references to the input ranges). Now that name can be used multiple times in a cell or in the workbook. In the example below the formula is the sum of the product between two fixed ranges and a nonsense formula in the shown cell uses this formula twice:
I have a workbook with different sheets for each month. I made another sheet where I put the months in A1 down.
I wanted to use Counta (for A:A in the months' sheets) and indirect together but I am getting the result "1" with my formula.
Please help:
=COUNTA(INDIRECT(SheetNames!A1&"!A:A"))
I would also eventually like to do the same for countif. If you can please explain what I missed that will help me.
Thanks!
Trying out your formula it works perfectly unless you've got a space in the worksheet name.
Try this formula:
=COUNTA(INDIRECT("'" & SheetNames!A1 & "'!A:A"))
When a sheet name contains a space then the sheet name must be enclosed within apostrophes. So =COUNTA('Sheet 4'!A:A) is a valid formula, while =COUNTA(Sheet 4!A:A) will not work and causes all kinds of problems.
The INDIRECT formula needs a valid reference as a string (rather than an actual reference) to calculate - so "'" & SheetNames!A1 & "'!A:A" returns the string 'Sheet 4'!A:A.
So I have a tab for every month's worth of data, and then I have a summary that references the current month's sheet. Is there any way I can put "April 2015" (this would be the name of the sheet) in cell A1, and then have formulas like:
=COUNTIFS('(String in A1)'!$I$10:$I$149,B4,'(String in A1)'!$L10:$L149,"")
That way I'd only have to edit the 1 cell and I'd know all the references are correct whereas if one of the formulas don't get replaced, I'd be referring to a month behind on one random cell and likely never even know.
Seems like that should be very simple, but I can't seem to figure out how.
Be careful to preserve those single quotes:
=COUNTIFS(INDIRECT("'" & A1 & "'!$I$10:$I$149"),B4,INDIRECT("'" & A1 & "'!$L10:$L149"),"")