+ Reply to Thread
Results 1 to 3 of 3

Excel 2007 : Use a variable instead of a hard coded value

Hybrid View

  1. #1
    Registered User
    Join Date
    12-05-2011
    Location
    Cincinnati, OH
    MS-Off Ver
    Excel 2007
    Posts
    40

    Question Use a variable instead of a hard coded value

    Hi folks,

    This should be an easy one.

    Below is a line of code that works fine:

    ActiveChart.SeriesCollection(2).Values = "='AIO-Cond'!$L$4:$L$6725"
    But instead of the hard coded value 6725, I want to use my variable LastRow (Dim as Integer).

    How should I format the new code? I have tried simple things like:

    ActiveChart.SeriesCollection(2).Values = "='AIO-Cond'!$L$4:$L$ & LastRow"
    And I get '1004' errors.

    Can you folks tell me how to do this right, or if not "right" just so it will work?!

    - Thomas
    Last edited by ThomasHaller; 12-15-2011 at 01:45 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,280

    Re: Please help me use a variable instead of a hard coded value.

    You were close:
    ActiveChart.SeriesCollection(2).Values = "='AIO-Cond'!$L$4:$L$" & LastRow
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    12-05-2011
    Location
    Cincinnati, OH
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Please help me use a variable instead of a hard coded value.

    Woohoo! Thanks romperstomper! I am even learning from these answers!!

    - Thomas

+ 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