+ Reply to Thread
Results 1 to 3 of 3

VBA : Convert Range in Chart to an Array

  1. #1
    Registered User
    Join Date
    03-25-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    34

    VBA : Convert Range in Chart to an Array

    I am having issues figuring out how to add a chart with vba, I have coded several things and seem to be getting the right result now. The problem is I would like to use a vector/array to store the data that is to be plotted. I am not being successful with this, I can only get vba to plot with a range from a specific sheet. The successful script is :

    ActiveChart.FullSeriesCollection(1).Name = "=Sheet1!$D$1:$D$6"
    ActiveChart.FullSeriesCollection(1).Values = "=Sheet1!$E$1:$E$6"
    ActiveChart.FullSeriesCollection(1).XValues = "=Sheet1!$D$1:$D$6"

    but what i want is something like this:

    NameArray = Array(1,2,3......)
    ValueArray = Array(1,2,3......)
    XValueArray= Array(1,2,3......)

    ActiveChart.FullSeriesCollection(1).Name = NameArray
    ActiveChart.FullSeriesCollection(1).Values = ValueArray
    ActiveChart.FullSeriesCollection(1).XValues = XValueArray

    With this method I would be able to create a array repository for my data that is dynamic in code vs a static spreadsheet value.

    Any help with this would be appreciated!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: VBA : Convert Range in Chart to an Array

    You would normally do that by creating Dynamic Named Ranges for each of the series and using those in the charts instead of the static ranges.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: VBA : Convert Range in Chart to an Array

    You can use Application.Transpose() or Application.Index().

+ 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. Replies: 4
    Last Post: 04-25-2017, 11:01 AM
  2. Get chart series from an array that has NOT been filled with a range
    By Woulter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-25-2016, 06:32 PM
  3. [SOLVED] Unable to convert array to range while performing Autofilter
    By sreeks in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2016, 01:12 AM
  4. How to convert a range of numbers to sequence of numbers in an array
    By MetisConnect in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-25-2015, 11:53 AM
  5. Need to use/convert values in specific range as/to an array
    By s4driver in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-18-2013, 06:46 AM
  6. Convert a Range to an Array
    By nsorden in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-08-2009, 01:28 PM
  7. Create chart using data array (not range)
    By Pingu in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-07-2009, 12:17 PM

Tags for this Thread

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