Dynamic range (object variable error)

M

Mslady

Hello all,

I need help selecting a range for my chart. The number of rows ar
always going to change. Right now, my code selects A1:E12 and it work
perfectly as long as data is exactly that range, but anything more o
less than that gives errors.

I am trying to select the first and last cell (range for the char
creation), please see code below. but i get "runtime error 91: objec
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 Where:=xlLocationAsObject, Name:="TradeVolume-Chart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top