views:

14

answers:

2

I made a XY plot that shows points from one data set in two different colors, depending on a set of conditions. I achieved this by making the source table three columns instead of two. First column is the X. Second column is Y is one set of conditions apply, third column is Y is the other set of conditions apply. So the second and third columns have formulas like this in them, respectively:

=IF(ConditionApplies,YValue,"")
=IF(ConditionApplies,"",YValue)

(So the graph actually has two series, each of which is not a contiguous block of numbers - each is interspersed with "nothing")

When I make a change that affects the ConditionApplies, the table reacts properly. Then I switch to the chart (on a different sheet) and it always says: "A formula in this worksheet contains one or more invalid references...". Click OK.

The chart itself always looks the way I would expect, with two different sets of points according to the Conditions I devised. If I inspect the data source fields, all the references are intact and proper.

Basically everything works, I would just like to avoid this annoying pop-up.

Thanks!

+1  A: 

I 100% understand everything you've said here and, on the surface, it sounds like it's not any kind of bug. It seems like you are actually referencing something you shouldn't. If that's, in fact, the case that's obviously something you want to fix.

My first guess would be to look at your "ConditionApplies" formulas. Under certain cases, would they create invalid references (referencing data of the wrong type, dividing by zero, circular references, etc.). The most common cause of problems like that would be dragging formulas but not having the "$" signs in the appropriate places. So your cell references change when you expected they'd stay the same.

For example:

=SUM(A1:G25)

should be something like the following to prevent the column and row from incrementing when dragged:

=SUM($A$1:$G$25)


Recommendation

Look at the "ConditionApplies" formulas (or better yet, post them here) and aggressively place $ where ever they don't break things. Then "re-drag" your new formulas, updating the previous ones.

gmale
Hi, the problem is resolved. I am not 100% sure of the original root cause. I make heavy use of range names, so even though the advice about absolute addressing is good, it doesn't apply directly to my situation. However, I am generating some of the named ranges in VBA code, and I think one of them was overextended by one row. i think this was the root cause, but can't prove it. Now that the code is all tidied up, it works like a charm. Thanks!
KnomDeGuerre
No problem, glad you got it working! Sometimes, I wish there was a way to walk through Excel's errors, step by step to find the exact point of failure, like it was software. Usually, I end up having to do that manually--breaking tricky formulas or VBA functions into small parts and testing each piece. If this problem springs back up, I would start breaking down your VBA code into atomic parts, making short functions that do only one thing. Then, it becomes very easy to test and pinpoint problems, stepping through the debugger. Hope that helps.
gmale
A: 

See comment under gmale's answer

KnomDeGuerre