+ Reply to Thread
Results 1 to 7 of 7

Set Source Data for Scatter Chart

  1. #1
    Registered User
    Join Date
    02-27-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    20

    Set Source Data for Scatter Chart

    Hi,
    I'm trying to find a way to use VBA to set the data source range in a scatter chart.
    At the moment the scatter chart uses the range A2:B18 which has been named "chart_range".
    When I try and add "chart_range" to the source data field it fails with the following error message "Object doesn't support this property or method".
    There are limitations in Excel with using dynamic data source range in a scatter chart but was wondering if anyone might have an alternative solution.

    Many thanks for any help

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,749

    Re: Set Source Data for Scatter Chart

    Please show your actual code.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Spammer
    Join Date
    01-26-2010
    Location
    Worcester MA
    MS-Off Ver
    Excel 2003
    Posts
    184

    Re: Set Source Data for Scatter Chart

    You need to reference the name to the sheet it's on using 'Sheet 1'!chart_range
    Jon Peltier
    http://PeltierTech.com/

  4. #4
    Registered User
    Join Date
    02-27-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Set Source Data for Scatter Chart

    thanks for your replies.

    Here is the code:
    Range("D14:E" & LastRow).Select
    ActiveWorkbook.Names.Add Name:="PivotScatterRange", RefersTo:=Selection
    ActiveSheet.ChartObjects("Chart 1").SetSourceData Source:=Range("PivotScatterRange")

    I think I'm missing the reference back to the sheet (as you mentioned) but am unable to get it right.

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

    Re: Set Source Data for Scatter Chart

    You're missing a reference to the actual chart:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  6. #6
    Spammer
    Join Date
    01-26-2010
    Location
    Worcester MA
    MS-Off Ver
    Excel 2003
    Posts
    184

    Re: Set Source Data for Scatter Chart

    ... and to the sheet, though if it's the active sheet, it's assumed. Better to be obsessive about it than burned by a bad assumption.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-27-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Set Source Data for Scatter Chart

    Thank you! It works very well!

+ 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. Setting the source data of XY scatter chart in VBA
    By jshaw82 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-17-2013, 05:38 PM
  2. [SOLVED] Exclude one data series from scatter chart legend (but not from the chart)
    By JayUSA in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-29-2012, 05:24 PM
  3. Link back to source data from a point in a scatter plot?
    By Riverglen in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 03-18-2012, 10:34 AM
  4. [SOLVED] A scatter plot with a 2 column data source
    By SamB in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-12-2006, 06:55 PM
  5. [SOLVED] Adding more source data to existing scatter plot
    By Tom in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-21-2005, 06: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