+ Reply to Thread
Results 1 to 8 of 8

Add custom error bars from data adjacent to series data using VBA

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010, 2013
    Posts
    17

    Add custom error bars from data adjacent to series data using VBA

    I have a chart that contains several series of data that are organized under the same columns. For example, Series1 = (C3:C9,G3:G9), Series2 = (C10:C16,G10:G16), etc. I want to use a macro that automatically adds custom error bars whose positive and negative ranges are one column to the right of the series Y-data, e.g. H3:H9 for Series1. Below is my attempt at the code but I have difficulty defining the error bar range (see Line 6). I would like the macro to add error bars to all series in the chart. Anybody have suggestions?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Add custom error bars from data adjacent to series data using VBA

    what does the variable txt contain? Is it a valid range reference?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,615

    Re: Add custom error bars from data adjacent to series data using VBA

    in line 5 your srsYval is assigned a String value which probably looks like:
    "Sheet1!$G$3:$G$9" or similar
    for sure it is not good value to be used as argument for Range.
    May be it is enough if you dig-out cell address (for instance again with split).
    So try:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  4. #4
    Registered User
    Join Date
    01-04-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010, 2013
    Posts
    17

    Re: Add custom error bars from data adjacent to series data using VBA

    Andy,

    "txt" is a reference to the Series. The code [ActiveChart.SeriesCollection(i).Formula] gives "=SERIES("Series1",Sheet1!$C$3:$C$9,$G$3:$G$9). I was using this to get ($G$3:$G$9) for the Y-values, then ideally use OFFSET to get the corresponding error values one row to the right.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Add custom error bars from data adjacent to series data using VBA

    post example workbook

  6. #6
    Registered User
    Join Date
    01-04-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010, 2013
    Posts
    17

    Re: Add custom error bars from data adjacent to series data using VBA

    Andy,

    Here is the example workbook. I have four series whose names are in Col B, x-values in Col C, y-values in Col F and error values in Col G. Ideally, the macro should capture the references to the y-values (e.g. Sheet1!$F$3:$F$9) and offset it to the error values (Sheet1!$G$3:$G$9) and use that reference to create custom error bars.
    Attached Files Attached Files

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Add custom error bars from data adjacent to series data using VBA

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-04-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010, 2013
    Posts
    17

    Re: Add custom error bars from data adjacent to series data using VBA

    guys,

    looks like I got it figured out. one of the issues what the ErrorBar Type, which I changed to "xlErrorBarTypeCustom" (refer to link). I kept srsYval as the entire reference. I added a line to turn off x-error bars. I also cleaned up some of the code. Let me know if you have any suggestions on improving the code.
    Thanks for the help!
    Please Login or Register  to view this content.

+ 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. Error Bars by Data Point instead of Series
    By riwiseuse in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 12-06-2010, 05:40 PM
  2. How to I incorporate SD from a data series into chart error bars?
    By carlosPharm.D in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 08-02-2005, 05:05 PM
  3. How do I set different error bars per data point in a series
    By Trebor1 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-03-2005, 09:05 AM
  4. Error bars for a single data point not whole series
    By Helen in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-13-2005, 02:06 PM
  5. [SOLVED] format one data series, with error bars, and use it as default
    By JBR in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-09-2005, 12:06 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