+ Reply to Thread
Results 1 to 3 of 3

Find Range for FullSeriesCollection .Name and .Value

Hybrid View

dflak Find Range for... 11-01-2017, 01:49 PM
dflak Re: Find Range for... 11-01-2017, 04:39 PM
dflak Re: Find Range for... 11-01-2017, 04:59 PM
  1. #1
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Find Range for FullSeriesCollection .Name and .Value

    I have a couple of applications where the sheet data are identical in location. What I want to do is "clone" the chart on one of the sheets to the other sheets. If I copy the chart to a new sheet, it still references back to the old location. The "fix" is to activate the chart on the new sheet, go to Select Data and edit each series by changing the name of the sheet from the old sheet to the new sheet.

    I would like to automate this process. So I recorded a macro and here's a part of it.
        ActiveChart.FullSeriesCollection(1).Name = "='Page 2'!$A$2"
        ActiveChart.FullSeriesCollection(1).Values = "='Page 2'!$B$2:$D$2"
    When I try to reference ActiveChart.FullSeriesCollection(1).Name , I get the contents of cell A2 on page 2. I don't get "='Page 2'!$A$2". I will need to do that so I can write my program.

    I can't even reference ActiveChart.FullSeriesCollection(1).Values, but I need to find how to get the "='Page 2'!$B$2:$D$2" part.

    So far, everything I've researched tells me how to set these values. In other words, I can tell the chart where to read the data from. I can't tell where it is currently reading the data from.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Find Range for FullSeriesCollection .Name and .Value

    I finally found what I needed:

    ActiveChart.FullSeriesCollection(1).Formula
    Yields =SERIES('Page 2'!$A$2,'Page 2'!$B$1:$D$1,'Page 2'!$B$2:$D$2,1)

    Which are Series Name, Column Header Names, Series Values. All I have to do is parse them out and I am in business.

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Find Range for FullSeriesCollection .Name and .Value

    I didn't even have to parse. All I had to do was substitute. The original chart was on Page 1. I copied it to another sheet, selected the new sheet and ran the code.

    Sub SwitchSource()
    Dim MySeries As String              ' Series Formula
    Dim MyName
    Dim chObj As ChartObject            ' Pointer to chart objects on sheet
    Dim NSeries As Long                 ' Number of series
    Dim k As Long                       ' Index for series
    
    Dim TSheet As String                ' Template sheet
    Dim DSheet As String                ' Destination sheet
    
    ' inialize variables
    TSheet = "Page 1"                   ' Prompt or otherwise read this value
    DSheet = ActiveSheet.Name
    
    ' Future enhancement - loop thorough a list of sheets.
    
    ' Loop though charts
    For Each chObj In ActiveSheet.ChartObjects
        chObj.Activate
        ' Find number of series and loop through them
        NSeries = ActiveChart.FullSeriesCollection.Count
        ' Loop though the series, get the series string and change it
        For k = 1 To NSeries
            MySeries = ActiveChart.FullSeriesCollection(k).Formula
            MySeries = Replace(MySeries, TSheet, DSheet)
            ActiveChart.FullSeriesCollection(k).Formula = MySeries
        Next k
    Next chObj
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel 2003 FullSeriesCollection
    By Evolta in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-06-2015, 03:08 AM
  2. Find pairs of words in range, then find next pair
    By brent.fraser in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-06-2014, 12:31 PM
  3. Code to find named range doesn't find the correct field range?
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-12-2012, 05:54 PM
  4. [SOLVED] Using range.find to find two specific values in two columns
    By mhrub in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2012, 01:02 PM
  5. Range.Find to find column and place value in next available cell in one line
    By davegugg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2011, 10:41 AM
  6. find row no. of particular cell in a range and find last entry in that row
    By VishalGupta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-06-2011, 01:29 AM
  7. find, meet condition, sum range, deduce, find next
    By pinstripe in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-27-2007, 09:30 AM

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