Quirky graph problem

roscoe

Well-known Member
Joined
Jun 4, 2002
Messages
1,062
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have a fairly complicated graph whose underlying data is macro built and all of the data is plotted using dynamic named ranges. The macro starts by wiping out all legacy data and rebuilding it based on the new input parameters. Up to now this has worked fine. Note that (1) this all runs in one macro and (2) one step in the macro is to redefine the dynamic named ranges with code (not that they change; I just never deleted that step).

I recently wrote a second macro to add 3 data series to the graph. This macro also blows away the old data (I'm guessing invalidating the dynamic named ranges) before rebuilding the new data (the graph series definitions remain based on the named ranges). Immediately after the macro runs the graph indicates an error in the graph data. I spent way too much time trouble shooting only to learn that if I simply save/close the file and reopen it the error goes away.

1) Is there a way to clear the error using code rather than close/reopen?
2) Will recreating the dynamic named ranges in the second macro fix the problem?

Otherwise, I may have to leave one row of data (to preserve the dynamic named ranges) and hope it all gets overwritten with valid data and leave behind a straggler.

Ideas?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
The error occurs because after you make the named ranges invalid, they are still referenced in the graph values.

If you delete the graph series definitions that use the named ranges, delete the named ranges, recreate those named ranges and recreate those graph series definitions, the errors you mentioned should not occur.
 
Upvote 0
I thought about that but was hoping for an easier solution.

Thanks
 
Upvote 0
Rather than blow away the series and recreate them with a ton of formatting tweaks, I just put some numbers in an out of the way place and before blasting the numbers and killing the range I simply redefine the range to this static location. Afterwards, I recreate the dynamic range. Seems to be working OK now...
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,220
Members
452,895
Latest member
BILLING GUY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top