Copying worksheets & maintaining dynamic range graphs

Mat_H

New Member
Joined
Feb 17, 2012
Messages
1
Ok I've trawled the internet for too long now and still not found a solution so I figured I'd finally register and post a problem...

I have a database which I can query (osisoft PI for any process engineers) and I've set up a sheet to identify the start and end points of certain events that I'd like to examine in more detail. Using this table of start and end points I copy a template which queries my database for the relevant time period - thus dragging the relevant data into the copy of the template.

The template contains a chart which references named ranges (if that's the correct term, I used insert-> name -> define) so that it is dynamic. I need it to be dynamic as the size of the data series depends upon how long the event is.

The template sheet gets copied and a whole new batch of named ranges is created for the sheet (e.g. temp(2)!named_range) which is great. Unfortunately the chart on the copied sheet continues to reference the named ranges on the template, not the template copy so I go about trying to sort this out, the closest i've come is with this code:

Code:
With ActiveChart
    .ChartArea.Select
    .SeriesCollection(1).XValues = Range("'" & ActiveSheet.Name & "'!selected_date")
    .SeriesCollection(1).Values = Range("'" & ActiveSheet.Name & "'!selected_value")

This changes the series data for the chart to the named ranges but it leaves them the size they are at that instance i.e. B1:B2 & C1:C2 rather than selected_date and selected_value. This means that the chart is no longer dynamic.

Thanks in advance for any advice and don't hesitate to ask if you think I can clarify the problem in any way!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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