+ Reply to Thread
Results 1 to 7 of 7

Is it possible to plot a chart strictly from VBA memory w/out linking it to data in cells?

  1. #1
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Smile Is it possible to plot a chart strictly from VBA memory w/out linking it to data in cells?

    I have a rather large workbook with bunch of worksheets data from which need to be charted. The charts remain stationary on the first page, but which workbook they chart changes on a constant basis, so rather than using the "indirect" function which takes up a lot of memory would like to see if I can simply absorb the data into VBA memory, and without importing it somewhere on the first sheet, chart it strictly from memory. Is that possible?

    Thanks
    Last edited by luv2glyd; 12-07-2015 at 11:35 PM.
    You either quit or become really good at it. There are no other choices.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Is it possible to plot a chart strictly from VBA memory w/out linking it to data in ce

    Are you saying that you have a completely separate workbook containing the chart data. If so have you considered creating a Data Connection to that workbook and have VBA change the connection link when necessary?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: Is it possible to plot a chart strictly from VBA memory w/out linking it to data in ce

    Actually, everything is in the same workbook - so sheet 1 would have the charts on it and sheets 1, 2, 3, 100, etc. will have the data. Yes, I've done what you are proposing before with separate CSV files containing data, but in this case the data is being written continuously (every few mins) to the individual worksheets and I need to regularly retrieve it into charts.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,460

    Re: Is it possible to plot a chart strictly from VBA memory w/out linking it to data in ce

    Possible? I expect that it is. You can use the .values property (and .xvalues property, if you need to change both x and y data) of a data series (https://msdn.microsoft.com/EN-US/lib.../ff840677.aspx has a list of available properties and methods for the series object). You can assign an array constant to these properties, or assign a range reference, as explained in the help file.

    Whether it would really use less resources to 1) read the data into VBA then 2) write the data to the chart series than using the INDIRECT() function in a worksheet, I cannot say. You would have to try it and see.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: Is it possible to plot a chart strictly from VBA memory w/out linking it to data in ce

    Ok, thank you. I'm just learning about VBA memory arrays and am totally unfamiliar with the jargon. Would you be able to give an example? How would you plot the following in a stock chart for example? This would be the open-high-low-close option under excel "Stock" in Excel stock chart type, requiring 4 columns of data. I'd have the chart already sitting in an excel workbook, so there's no need to create it with VB, just populate it with data.

    Here's an example of data in 4 columns that I am trying to plot:

    116.17 116.40 116.17 116.30
    116.49 116.79 116.48 116.54
    116.53 116.60 116.30 116.36
    116.32 116.48 116.21 116.30
    116.29 116.35 116.04 116.08
    116.07 116.12 115.95 116.12
    116.12 116.12 115.98 116.00
    116.00 116.08 115.96 116.02
    116.01 116.08 115.96 116.02

    Thank you

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,460

    Re: Is it possible to plot a chart strictly from VBA memory w/out linking it to data in ce

    This is not the kind of programming that I do, so I probably do not have any better examples than the ones in the help files.

    What jargon are you having trouble understanding? If it is about understanding how properties and methods work, this is probably one key to learning VBA (and other object oriented languages) -- learning how to navigate Excel's object model.

    As near as I can tell, an open-high-low-close chart should be like any other chart with 4 data series in it, at least as far as changing the values of the data series. I would expect the procedure to:
    1) Read the data -- it is not clear to me if you will want to read the data into a VBA array, or simply "copy" the data into the dashboard sheet. It sounds like you are asking to read it into a VBA array. From your other threads, I assume you already know how to do this.
    2) Loop through each data series in the series collection and assign the appropriate array to each data series .values property.

    Maybe something like (untested and incomplete):
    Please Login or Register  to view this content.
    I don't really know if this is more efficient than the INDIRECT() function, but that is kind of how I would expect it to work.

  7. #7
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: Is it possible to plot a chart strictly from VBA memory w/out linking it to data in ce

    Ok, thank you so much for your help and the example. I had to tweak it a bit, but works well. For future ref.:

    Please Login or Register  to view this content.
    Last edited by luv2glyd; 12-07-2015 at 11:37 PM.

+ 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. Copy and pasting data thats strictly in view
    By Paragoomba in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-14-2013, 03:13 PM
  2. Plot points on a area chart or plot areas on a scatter chart
    By maggy in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 01-17-2012, 04:39 AM
  3. How to plot a chart by linking a table to a particular cell
    By rahul.mehra25 in forum Excel General
    Replies: 1
    Last Post: 12-29-2009, 04:01 PM
  4. Plot 3 sets of data in scatter chart and area chart in one
    By geoffs52 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 12-24-2009, 04:42 AM
  5. Filter Data and Plot Bar-Chart
    By dejhantulip in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 07-28-2009, 03:27 PM
  6. How do I plot non-consecutive data on a chart?
    By jsnyder in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 10-20-2007, 02:43 PM
  7. How do i plot three different data on a same chart
    By Iqbal in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-17-2005, 01:08 AM
  8. Strange Problem with Chart and Plot Visible Cells Option
    By Marcus Leon in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-07-2005, 12:06 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