Data Label Values from Cells

Copper Contributor

Hi,

I have a line graph with data labels from a cell range.  It looks like this:  

='Template'!$CM$12:$CM$35

However, I have code that duplicates this worksheet many times; and I need each sheet's labels to refer to it's own label data range instead of the original Template.  When I try removing the sheet name from the label range in the Template, I get the message "The reference is not valid.  References for titles, values, sizes, or data labels must be a single cell, row, or column." 

=$CM$12:$CM$35 is a single column, so I'm not sure why this isn't working.  Any suggestions?

 

2 Replies

@ToddA2001 

Hi Todd,
This can be done.
The sheet name MUST always be in the chart reference.
Place this formula somewhere on the main spreadsheet.
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
This will call out the name of that spreadsheet in the cell you place this in, but only if you have already saved the workbook. It will call out the new name when a new spreadsheet is created. Use that name in an indirect formula that is part of a named range, and use that named range in place of the reference in the chart.
In my test, I put the above formula in cell G29. In cell d23 through j23 I placed random numbers, 1-7. I highlighted those 7 numbers and selected a simple bar chart, placing it next to the row of numbers. I named my first sheet tester and named the spreadsheet TRIAL.XLSX
In another random cell, I used D4, I put =INDIRECT("'"&$G$29&"'!$d$23:$j$23")
Mind all “, ‘ and $. Copy and paste this adjusting for the cells but do not change the syntax.
It should display the number that is in the row 29 cell it is over, but that does not really matter. We are wanting to make sure the indirect formula is working. Click on the formula in D4 and copy it.
Now, open the name manager under the Formulas tab.
Select New, and give it a name with letters only. I chose the word TRIBE for no reason. In the Refers to box, erase what is there and paste your indirect formula in it, making sure the = is there. Say ok. This should take you to a bigger box that displays all the names in the manager. Just close it.
Click on one of the bars in the chart to display the formula for the chart. It will look like SERIES(,,'tester'!$D$23:$J$23,1).
Change it to = SERIES(,,trial.xlsx!tribe,1)
That is using the name of the spreadsheet, not the worksheet, and the name of the range created in the name manager. As you copy this sheet, the tab name will change, and the indirect formula will pick that up. You can change the name of the tab and it will still work.
You do not need to keep all of the indirect formulas in the d4-j4 range.

@SqueakySneakers 

Thanks!  I'll give this a try soon.