Search code examples
excelchartsvba

Getting the range used to define error bars with VBA


I have an Excel chart. One of the series has X and Y error bars, defined from worksheet ranges.

I want to get via VBA those ranges (not set them). Is this possible?


Solution

  • Jon Peltier has an article about error bars on his blog here

    Quoting from that:

    Programmatically Defining Custom Error Bars

    The command to add error bars using Excel is: {Series}.ErrorBar Direction:={xlX or xlY}, Include:=xlBoth, Type:=xlCustom, _ Amount:={positive values}, MinusValues:={negative values} Values can be a single numerical value, for example, 1, an comma-separated array of numerical values in curly braces, such as {1,2,3,4}, or a range address in R1C1 notation. For values in Sheet1!$G$2:$G$10, enter the address as Sheet1!R2C7:R10C7. Combine both plus and minus in the same command. In Excel 2007, if you don’t want to show a particular error bar, you must enter a value of zero in this command. In 2003, you can enter a null string “”. In Excel 2003, the range address must begin with an equals sign, =Sheet1!R2C7:R10C7; Excel 2007 accepts the address with or without the equals sign. Single values or arrays may be entered with or without the equals sign in either version of Excel.

    In a post on Ozgrid, Jon Peltier says

    the range for custom error bar values is not exposed to VBA

    If Jon says it can't be done, it can't be done.