October 14, 2015
I'm having a problem defining the x-axis on a chart
Failed Approach 1:
I tried using the following formula:
=OFFSET(INDIRECT(ADDRESS(Sheet4!$K$2,1)),0,0,Sheet4!$L$2,1)
However, I get the error message: "Excel found a problem with one or more formula references in this worksheet"
I've successfully use OFFSET formulas to define chart axes before, so I'm wondering if perhaps the INDIRECT or ADDRESS formulas are not allowed in the SERIES formula defining a chart?
Failed Approach 2:
I have the addresses of the beginning and the end of the desired x-axis range in two separate cells, but can't figure out how to create a range reference that the SERIES function will accept. Can this be done?
Thanks!
July 16, 2010
Hi Bob,
I'm wondering why you can't just use OFFSET to derive the range. You've managed to get the cell addresses of the beginning and end cells, but I don't know how you've done this or if it can be skipped altogether.
Looking at your formula, if cell L2 contains a cell address then this isn't what OFFSET needs in this argument. It wants to know how many cells in the range.
Can you please upload your file as it will help answer these questions and more?
Mynda
Trusted Members
Moderators
November 1, 2018
October 14, 2015
Please see attached file.
The original data is in columns A, C and D. What I'm trying to do is create up to 7 charts to plot the daily cumulative totals of C & D (as a 2-line line chart).
I added column B as a helper column to make it easier to see when dates change. I added E and F to show the daily cumulative total of C & D. The original file was too large to update, so I changed columns B, C and D from (simple) formulas to values to reduce the file size.
The chart on the page was built by using the actual numeric data for day 1. I then created the table in H1 to N9, figuring that once I had the start and stop addresses, I could create the x-Axis range using "=OFFSET(INDIRECT(ADDRESS($J$2,3)),0,0,$K$2,1)"
That didn't work, so I tried
=INDIRECT(ADDRESS(2,14))&":"&INDIRECT(ADDRESS(2,14))
and
=INDIRECT($M$2)&":"&INDIRECT($N$2)
but neither of these worked either. I then created range names for each of the three formulas, but that didn't work either.
I did a few other experiments and it looks like I can't use the indirect function in a series function, but I'm not sure if that's really the problem.
Finally I tried the suggestion to add the sheet name, but OFFSET(INDIRECT(ADDRESS(sheet1!$J$2,3)),0,0,Sheet1!$K$2,1) didn't work either.
I'm obviously stumped, and would appreciate any help the community can offer.
Trusted Members
Moderators
November 1, 2018
October 14, 2015
I'm trying to define a range for the x-axis by using =OFFSET([starting cell],0,0,$K$2,1). The challenge is finding a formula that (in this case) resolves to A2 in place of [starting cell].
Based on the most recent suggestion, I started with "Sheet1!"&ADDRESS($J$2,1), which resolved to $A$2, so I thought I was done. However, when I put it into the OFFSET function, it resolved to "$A$2", which OFFSET wouldn't accept, since it's text, not a reference.
OK, so I tried to use SUBSTITUTE("Sheet1!"&ADDRESS($J$2,1),CHAR(34),"") to remove the quotes, which worked fine on its own. However, when I put it into the OFFSET function, it still resolved to "$A$2". Out of curiosity, I also tried =INDIRECT(SUBSTITUTE("Sheet1!"&ADDRESS($J$2,1),CHAR(34),"")), which worked perfectly, and gave me the contents of A2, as it should have.
Since both OFFSET and INDIRECT require a valid reference as the first parameter, why does INDIRECT accept SUBSTITUTE("Sheet1!"&ADDRESS($J$2,1),CHAR(34),"") as a valid reference, but OFFSET won't????
I feel like I'm overlooking something obvious, but I can't see what it is.
Trusted Members
Moderators
November 1, 2018
INDIRECT expects a text address, not an actual cell reference (which is what it returns). So you can use that to provide the necessary starting cell for OFFSET.
You will note that when you define a name, you have to specify a sheet for any cell references you use - if you simply use J2, the name manager will add a reference to the current sheet automatically so that the name has the correct context, no matter where you use it from. The same principle applies to charts - every range you use must be explicitly qualified to a particular sheet.
So, if you define a named range for the chart axis, it needs to look something like:
=OFFSET(INDIRECT("Sheet1!"&ADDRESS(Sheet1!$J$2,3)),0,0,Sheet1!$K$2,1)
October 14, 2015
I'm afraid I get the same result as before, even using the suggested formula of
=OFFSET(INDIRECT("Sheet1!"&ADDRESS(Sheet1!$J$2,3)),0,0,Sheet1!$K$2,1)
Namely, if I enter that formula into a cell, it evaluates properly; if I try to use it to specify the X-Axis for a chart, I get an error message.
It occurred to me to look back at previous projects where I had been able to use OFFSET to successfully define an X-Axis. I found 4 examples, and noticed that in each case, the first parameter (starting point) of the OFFSET function was a direct reference, not a formula. Could that possibly be the reason I can't get the formula above to work? I know I'm grasping at straws, but it seems that that's all that's left....
1 Guest(s)