Results 1 to 3 of 3

Defining graph series using VBA

Threaded View

  1. #1
    Forum Contributor
    Join Date
    03-15-2016
    Location
    Vancouver, Canada
    MS-Off Ver
    w 10, Excel 2016
    Posts
    125

    Defining graph series using VBA

    I have code that creates a graph from dynamic data. To do this I’m using a pre-created graph in a workbook that uses series in another worksheet in the same workbook. To change the graph – I just put new data in the worksheet cells that house the series data. The code works fine.

    This is a data sample
    junk1.png

    The challenge is I don’t know how to change the series through VBA so I’ve manually plugged in an end row value of $30.
    Junk2.jpg

    This creates a bunch of blanks in the graph when the data is less than 30 rows long.
    How can I set the correct series length with VBA code in the code below?


    Range1 = TimeStampCol & "1," & TotalCol & "1," & IPercentileCol & "1," & AllPercentileCol & "1" ' 
    RangeC = Range1 & "," & TimeStampCol & StartRow & ":" & TimeStampCol & Row & "," & TotalCol & StartRow & ":" & TotalCol & Row & "," & IPercentileCol & StartRow & ":" & IPercentileCol & Row & "," & AllPercentileCol & StartRow & ":" & AllPercentileCol & Row
    WB.Activate                                  
    WB.Sheets(GraphData).Range("A2:E99").ClearContents
    WB.Sheets(GraphDataSource).Activate
    WB.Sheets(GraphDataSource).Cells(1, 1).Select
    WB.Sheets(GraphDataSource).Range(RangeC).Select
    WB.Sheets(GraphDataSource).Range(RangeC).Copy WB.Sheets(GraphData).Cells(1, 1)   from
    WB.Sheets(ChartTemplateName).Copy after:=WB.Sheets(Sheets.Count)             ' Now copy the Chart over from the template
    ActiveSheet.Name = ChartName
    WB.Sheets(TrendChartName).Select
    Attached Images Attached Images

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Color Formatting of Graph Series (via Graph Series Label)
    By James McEwan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-26-2015, 06:51 AM
  2. [SOLVED] Move from one series to the next series in a graph shortcut
    By nredman in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 05-17-2014, 02:45 AM
  3. Defining series values range from a single cell
    By stegngas in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-29-2014, 12:36 PM
  4. [SOLVED] Second Axis for a Graph but with the same kind of graph for the two series?
    By Marceltcm in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-18-2013, 05:37 AM
  5. Replies: 0
    Last Post: 03-22-2012, 09:46 AM
  6. varied series for graph which adjusts series
    By sput_sput in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 12-06-2010, 02:54 PM
  7. series graph -- one series being added to another series
    By rich zielinski via OfficeKB.com in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 03-30-2005, 02:06 PM

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