+ Reply to Thread
Results 1 to 2 of 2

variable range automation

  1. #1
    Ryan Proudfit
    Guest

    variable range automation

    I have two identical tables side by side and I'm trying to use one line of
    code to work for both tables. How do I write a variable range?

    My code is as follows:

    If intColumns = 0 Then
    ActiveChart.SetSourceData Source:=Sheets("cbot").Range("A2:E30"),
    PlotBy:= _
    xlColumns
    Else
    ActiveChart.SetSourceData Source:=Sheets("cbot").Range("I2:M30"),
    PlotBy:= _
    xlColumns
    End If


    --
    Ryan Proudfit

  2. #2
    Tushar Mehta
    Guest

    Re: variable range automation

    What do you want to do?

    If you have to decide between two tables, you need a decision making
    statement and if you want to set a chart range you need a statement to
    do that. That's two statements. You could try and check if the IIF
    function will work within the SetSourceData. That is one statement to
    set the source range and one function which still comes to two
    'things' to do.

    --
    Regards,

    Tushar Mehta
    www.tushar-mehta.com
    Excel, PowerPoint, and VBA add-ins, tutorials
    Custom MS Office productivity solutions

    In article <59D5DF46-C8D2-47D8-9690-B81AD186F401@microsoft.com>,
    RyanProudfit@discussions.microsoft.com says...
    > I have two identical tables side by side and I'm trying to use one line of
    > code to work for both tables. How do I write a variable range?
    >
    > My code is as follows:
    >
    > If intColumns = 0 Then
    > ActiveChart.SetSourceData Source:=Sheets("cbot").Range("A2:E30"),
    > PlotBy:= _
    > xlColumns
    > Else
    > ActiveChart.SetSourceData Source:=Sheets("cbot").Range("I2:M30"),
    > PlotBy:= _
    > xlColumns
    > End If
    >
    >
    >


+ 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