Hi. I am using Excel 2003.
I used the macro recorder and modied some of the code in the hopes that the
VBA I wrote work work. Instead, it produces errors. I have a Chart object on
a Sheet that I wish to "feed" a range to chart. Since the number of rows for the
needed range changes from time to time, I included a variable called amtrows.
Then I try to "assign" a range to variable XTemp. Then I try to feed that XTemp
range into the Chart object.
My modified code errors at this line --
Set XTemp = Sheets("Sheet5").Range("C1").Resize(amtrows, 1)
And at these lines as well --
ActiveChart.SetSourceData Source:= XTemp, PlotBy :=xlColumns
ActiveChart.SeriesCollection(1).XValues = Range(TimeFrame)
Could you please review my code below and tell me what to change ? I would be most
grateful for your help. Thank you.
WayneK
Sub ModifyChart1()
Dim amtrows As Long
Dim XTemp As Range
amtrows = Sheets("Sheet5").Range("A8").Value
Set XTemp = Sheets("Sheet5").Range("C1").Resize(amtrows, 1)
Set TimeRange = Sheets("Sheet3").Range("C7").Resize(amtrows, 1)
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:= XTemp, PlotBy :=xlColumns
ActiveChart.SeriesCollection(1).XValues = Range(TimeFrame)
ActiveWindow.Visible = False
Range("A1").Select
End Sub
Bookmarks