+ Reply to Thread
Results 1 to 8 of 8

How do I get gaps in a chart with values from an array using VBA?

  1. #1
    Registered User
    Join Date
    07-31-2014
    Location
    Norway
    MS-Off Ver
    2013
    Posts
    7

    How do I get gaps in a chart with values from an array using VBA?

    Hi

    I am trying to make a plot using VBA.
    I am storing the values I want to plot in arrays, but I also want to have some gaps in the plot.
    I found this really helpfull site: http://peltiertech.com/WordPress/vba...-excel-charts/.
    But since I am storing the values in arrays, another problem occurs.
    I want to insert "" where the gaps should be, and want to have numeric values elsewhere.

    How should I declare the arrays?

    If I use
    "Dim Array As Variant"
    all the points in the plot becomes zero.

    If I use
    "Dim Array As Double" or
    "Dim Array As Long" I get an "Type Mismatch" when I try to insert the empty ""s.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: How do I get gaps in a chart with values from an array using VBA?

    Can you define as variant and pass in ""'s or null? But check that its not text before insertion.
    Please Login or Register  to view this content.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    07-31-2014
    Location
    Norway
    MS-Off Ver
    2013
    Posts
    7

    Re: How do I get gaps in a chart with values from an array using VBA?

    Hm, then I got a Type mismatch when I wrote
    "ActiveChart.SeriesCollection(1).Values = arr"

    But i kind of solved it. I just made another array "Gaps" that stored the indices where the gaps should be. and then checked if the points were in Gaps when I edited the markerstyle.

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: How do I get gaps in a chart with values from an array using VBA?

    If your x-axis is at 0, can you not just add 0's?

  5. #5
    Registered User
    Join Date
    07-31-2014
    Location
    Norway
    MS-Off Ver
    2013
    Posts
    7

    Re: How do I get gaps in a chart with values from an array using VBA?

    I dont want any lines around the gaps. If I add 0's, there will be lines from the points around the gaps and down to the xaxis which I dont want. It is more or less the same problem as explained in this site: http://peltiertech.com/WordPress/vba...-excel-charts/.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: How do I get gaps in a chart with values from an array using VBA?

    I want to insert "" where the gaps should be, and want to have numeric values elsewhere.

    How should I declare the arrays?

    If I use
    "Dim Array As Variant"
    all the points in the plot becomes zero.

    If I use
    "Dim Array As Double" or
    "Dim Array As Long" I get an "Type Mismatch" when I try to insert the empty ""s.
    If you look carefully at Jon's code in his tutorial, he declares the vxvals and vyvals variables as variants. At the very end, he explains that there can be some different behavior in how it will treat string entries depending on how you populate these two arrays. My first piece of advice would be to make certain you are populating these variants/array exactly the same as Jon does.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  7. #7
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: How do I get gaps in a chart with values from an array using VBA?

    HI

    Ive just done it from the info you sent. Are your x axis numbers?

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: How do I get gaps in a chart with values from an array using VBA?

    hi annabroyn, it would help if you can you post your file with the coding

+ 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. Remove gaps for missing values in column chart
    By Mthes in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-22-2014, 05:20 AM
  2. timeline bar chart with gaps, ranges
    By ysrini in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-08-2009, 05:09 AM
  3. Not Able to Leave Gaps on Line Chart
    By ChristiaanV in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-14-2008, 05:09 AM
  4. I want to show gaps in my line chart
    By rshackleford310 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-09-2007, 02:19 AM
  5. [SOLVED] I get gaps in bar chart when using weekday values only in x-axis
    By Björn Elfvin in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 02-01-2005, 10:06 AM

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