I am attempting to use VBA in Excel to offset a series of charts by moving their data range down one row (I.E Week 1 will be A:74 and C:74, week 2 will be A:75 and C:75 etc)
I'm new to VBA and figured a simple Offset command would meet my needs but none of the code I put together will run without errors.
Here are some examples of Code I attempted:
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.SetSourceData Source:=Offset(1, 0)
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.Offset(1, 0).Select
I expected the Range of the Active Chart or Cell would have been Offset by 1 Row, 0 columns.
However, the first attempt gave the error:
Compile Error:
Sub or Function not defined
The second attempt gave the error:
Compile Error:
Method or data member not found
Not sure where to go with the errors as most of the other pages I looked at involve setting specific cell ranges for the offset function and I need this to ignore hard coded ranges and dynamically look at the ranges the current chart has selected and just move it all down by one, basically going from Weeks 2 - 8 to Weeks 3 - 9.
Any help would be greatly appreciated!
Offsetis a property of theRangeobject. So you need to define your source data using a range variable and then offset that.OFFSETexcel sheet equation to get same similar results