+ Reply to Thread
Results 1 to 4 of 4

Dynamic range (object variable error)

  1. #1
    Registered User
    Join Date
    10-04-2005
    Location
    NYC <--> Lagos
    Posts
    24

    Question Dynamic range (object variable error)

    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?

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    10-04-2005
    Location
    NYC <--> Lagos
    Posts
    24
    please help

  3. #3
    Registered User
    Join Date
    10-04-2005
    Location
    NYC <--> Lagos
    Posts
    24
    *sighs....

  4. #4
    Gary Keramidas
    Guest

    Re: Dynamic range (object variable error)

    try this instead

    Range ("A1:E" & end_row)

    of Range("A" & end_row)

    --


    Gary


    "Mslady" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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 Where:=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
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1