RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 790
- Office Version
- 365
- Platform
- Windows
Hi guys,
I have a nice one here but I can't quite wrap me head around it.
There are 15 charts on worksheet "grf" and they are handily named "Chart 1", "Chart 2" etc
I'd like to be able to change the source data for each of the sheets which is on sheet "wrk" (Workings)
Here's how I'm attempting to do it:
The idea here is that Chart 1 corresponds to line 3, Chart 2 corresponds to line 4 etc. The header is on row 2.
The problem I have is that the range(cells()) method clearly only works for a chunk of data and not two separate lines, which is what I need.
If I can R1C1 the range that would help... alas... I can not.
Any ideas? Thanks.
I have a nice one here but I can't quite wrap me head around it.
There are 15 charts on worksheet "grf" and they are handily named "Chart 1", "Chart 2" etc
I'd like to be able to change the source data for each of the sheets which is on sheet "wrk" (Workings)
Here's how I'm attempting to do it:
VBA Code:
Dim x As Integer
Dim Rng As Range, Hdr As Range
Set wrk = Worksheets("Workings")
Set grf = Worksheets("Graphs")
LUC = wrk.Range("AR2").Column
Set Hdr = wrk.Range(Cells(2, LUC - 12), Cells(2, LUC - 1))
x = 1
For x = 1 To 15
Set Rng = wrk.Range(Cells(x + 2, LUC - 12), Cells(x + 2, LUC - 1))
ActiveSheet.ChartObjects("Chart " & x & "").Activate
'ActiveChart.SetSourceData Source:=Sheets("Workings").Range("AG2:AQ2,AG7:AQ7") '(Original)
ActiveChart.SetSourceData Source:=Sheets("Workings").Range("Hdr", "Rng")
Next x
The idea here is that Chart 1 corresponds to line 3, Chart 2 corresponds to line 4 etc. The header is on row 2.
The problem I have is that the range(cells()) method clearly only works for a chunk of data and not two separate lines, which is what I need.
If I can R1C1 the range that would help... alas... I can not.
Any ideas? Thanks.
Last edited: