Posted to microsoft.public.excel.programming
|
|
Dynamic range (object variable error)
try this instead
Range ("A1:E" & end_row)
of Range("A" & end_row)
--
Gary
"Mslady" wrote in
message ...
Hello all,
I need help selecting a range for my chart. The number of rows are
always going to change. Right now, my code selects A1:E12 and it works
perfectly as long as data is exactly that range, but anything more or
less than that gives errors.
I am trying to select the first and last cell (range for the chart
creation), please see code below. but i get "runtime error 91: object
variable not set". What am i doing wrong? :)
Code:
--------------------
Dim end_row As Long
'Set end_row = Sheets("TradeVolume-Chart").Range("A65536").End(xlUp).Row
ActiveSheet.Columns("A:E").Select
end_row = Range("A65536").End(xlUp).Row
Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:="Line -
Column on 2 Axes"
ActiveChart.SetSourceData Source:=Sheets("TradeVolume-Chart").Range("A" &
end_row), PlotBy:=xlColumns
'ActiveChart.SetSourceData
Source:=Sheets("TradeVolume-Chart").Range("A1:E12"), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="TradeVolume-Chart"
--------------------
--
Mslady
------------------------------------------------------------------------
Mslady's Profile:
http://www.excelforum.com/member.php...o&userid=27776
View this thread: http://www.excelforum.com/showthread...hreadid=480837
|