Retain Chart Formatting when change series references

brianhfield

New Member
Joined
Mar 28, 2024
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello! I use named ranges in charts and VBA to change the named ranges so that I can update hundreds of charts in an automated fashion. Let's assume a have a chart that has series1 named range1 and series2 named range2 and i want to use vba to change this so that series1 references named range range3 and series2 references named range range4. I can do all of this successfully.
However, if I copy the chart from sheet1 and paste it into sheet2, and then I execute a vba script that replaces the series references, the chart formatting reverts to the default formatting and I lost the formatting from the original set of charts. Does anyone know how I can prevent excel from resetting the chart formatting when the series names are changed?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
I'd suggest you try the following.

1. Create your 'formatted' graph and right click on it.
2. Choose Save as Template... and save it with a name of your choice.
3. Copy the graph to Sheet2 and run your vba script.
4 Now start the macro recorder and record the following: On the Insert menu->Charts Group click on Recommended Charts->All Charts tab->Templates and select your template.
5. The template will be applied to your new graph.
6. Stop the macro recorder and add the recorded code to your existing code that changes the references.
 
Upvote 0

Forum statistics

Threads
1,221,526
Messages
6,160,340
Members
451,637
Latest member
hvp2262

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