This is my first time here. I am using Excel 2003 and am
self-taught in using VBA, and am still "green" in this area.
I used the macro recorder and modied some of the code in the hopes
that the VBA I wrote would 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 = Range("C1").Resize(x, 0)
And at this line as well --
ActiveChart.SetSourceData Source:=Sheets("Sheet5").Range(XTemp),
PlotBy _ :=xlColumns
Could you please review my code below and tell me what to change ?
I would be most grateful for your help. Thank you and God bless you.
Dim amtrows As Long
Dim XTemp As Range
amtrows = Range("A8").Value
Set XTemp = Range("C1").Resize(x, 0)
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=Sheets("Sheet5").Range(XTemp),
PlotBy _
:=xlColumns
ActiveWindow.Visible = False