Graph Data Range change based on current month

raj08536

Active Member
Joined
Aug 16, 2007
Messages
322
Office Version
  1. 365
Platform
  1. Windows
Hello

I have recorded a macro to change the Select Data

Sub TestMacro2()
'
' Macro2 Macro
'

'
ActiveSheet.ChartObjects("Chart 35").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData Source:=Range("A142:E150")
End Sub

I am now trying to automate to pick up cell values to change the range of data. Please check

Sub ChrtRngChg_EP()

Dim CM As Variant
Dim RNGColB_EP As Variant
Dim RNGRowB_EP As Variant
Dim RNGColE_EP As Variant
Dim RNGRowE_EP As Variant


CM = Sheets("Parameters").Cells(5, 2).Value
RNGColB_EP = Sheets("Parameters").Cells(2, 16).Value
RNGRowB_EP = Sheets("Parameters").Cells(2, 18).Value
RNGColE_EP = Sheets("Parameters").Cells(2, 17).Value
RNGRowE_EP = Sheets("Parameters").Cells(2, 19).Value



Sheets("Eight Pillars").Select

ActiveSheet.ChartObjects("Chart 35").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData Source:="=Range(" & RNGColB_EP & RNGRowB_EP & ":" & RNGColE_EP & RNGColE_EP & ")"



End Sub

It's give me error is the last line
1627418461983.png


Please help.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I appreciate your suggestion.
This particular excel file has 50 tabs and each tab has atleast 15 graphs. I can't create 750 tables and named range. Therefore, I want to write a vba for updating range for charts.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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