Results 1 to 4 of 4

How to shift chart source data xx number of rows down?

Threaded View

  1. #1
    Registered User
    Join Date
    05-01-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    How to shift chart source data xx number of rows down?

    Hi all,
    I'm a complete beginner to VBA, I'm building a big dashboard with repeating tables and charts. All data are located in columns AC:AO in a table of 59 rows, all charts are located in columns E:AA. When building the dashboard I always take last 59 rows and copy below, but the charts source data obviously don't update, so I'm trying to write a macro that would update the source data of a selected chart = shift the source data 59 rows down. It should be simple, I just don't know how to make a relative reference to the current source data in the chart I select. I have 4 different series of data located in different rows of the 59rows table.
    This is what I currently have, but it doesn't work

    Sub Change_Source()
    Dim myDataRow1 As Long, myDataRow2 As Long
    myDataRow1 = Range("AD10").Offset(59, 0)
    myDataRow2 = Range("AO10").Offset(59, 0)
    With ActiveChart
    ActiveChart.SeriesCollection (1)
    .Values = Range(myDataRow1, myDataRow2)
    ActiveChart.SeriesCollection (2)
    .Values = Range(myDataRow1, myDataRow2)
    ActiveChart.SeriesCollection (3)
    .Values = Range(myDataRow1, myDataRow2)
    ActiveChart.SeriesCollection (4)
    .Values = Range(myDataRow1, myDataRow2)
    End With
    End Sub

    Thanks so much for an advice, it would save me HOURS of time....

    hana
    Attached Files Attached Files

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