Can someone help me understand why I can't use the folling code to autoplot in a file?
Range(Cells(2, 1), Cells(variable, 2)).Select
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets(sheetname).Range(Cells(2,_ 1), Cells(variable, 2)), PlotBy:=xlColumns
My code runs right thru the first Range selection without a problem but when I want to designate source data, it doesn't like it.
I need to do it this way because the files I am plotting are of variable rows. I use a counter to count down until there is no data in a row then the variable is the row number that all the plots need to go to.
I tried concatenating the variable number with the other method for range selection
Range("A2:B"&variable) type of thing but that doesn't work either.
Any ideas on what might be the problem or how I might use a variable in the range selection process???
Thanks