Help: Dynamic Source Data for Column Chart

MarshHill

New Member
Joined
Jul 2, 2015
Messages
6
Hello,

I currently have a spreadsheet that automatically calculates data and populates a 12 month chart. However, I do not want to delete the previous months data that was generated, but I am having trouble selecting a dynamic range with static legend data. I want all of the data from previous months to be available, while changing the data to the current 12 month period. I would like to do this by adding the new data to the bottom, and selecting the data from the previous 12 months using an offset.

Any help would be greatly appreciated!

My current code that comes close to selecting the correct data is as follows:

Sub Charting()
Dim ChartRange As Range

Set ws = ActiveSheet

Set rng = ws.Columns("K").Find("*", ws.[K1], xlValues, , xlByRows, xlPrevious)
'Finding bottom of the data
rng.Offset(1, 1).Select

'12 month data selection

Set ChartRange = Range(Selection, Selection.Offset(-35, -11))

ActiveSheet.ChartObjects("Chart 2").Activate

'This is where I am having issues, because it selects all of the data, instead of the static legend and the dynamic range
ActiveChart.SetSourceData Source:=Range("$A$1:$L$1", ChartRange), PlotBy:=xlColumns

End Sub
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try this...

ActiveChart.SetSourceData Source:=Range("A1:L1, " & ChartRange.Address), PlotBy:=xlColumns

This defines a range with two areas.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,277
Messages
6,171,153
Members
452,383
Latest member
woodsfordg

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