Error bar macro does not work with Excel2007

Geert1968

New Member
Joined
Oct 23, 2008
Messages
6
Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
I'm new here, so let me give a short introduction. My name is Geert, I'm from the <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:eek:ffice:smarttags" /><st1:country-region w:st="on"><st1:place w:st="on">Netherlands</st1:place></st1:country-region> and I'm using Excel/VBA for my work.<o:p></o:p>
<o:p></o:p>
Right now I'm adapting an existing macro that was developed with Excel 2003, and I'm adapting it to work under Excel 2007.<o:p></o:p>
<o:p></o:p>
The macro collects data from a measurement instrument, filters it and makes tables and charts of selected data. The charts have a zoom function, so they work with dynamic named ranges.<o:p></o:p>
<o:p></o:p>
One of the features of the macro is that the user can convert a standard XY chart of data into a step chart. The step chart is not a standard excel chart but is made by using the error bars option. This method was found elsewhere on the web.<o:p></o:p>
<o:p></o:p>
Problem right now is that the step chart option does not work anymore, and the point of failure is when a named range is used to define the Y-error bar length. <o:p></o:p>
<o:p></o:p>
To illustrate the problem, I have made a simplified example workbook with simplified macro code. I will give these here:


screenexcelgw9.jpg
<o:p></o:p>

<o:p></o:p>
<o:p></o:p>
Sub step_chart()<o:p></o:p>
Dim X_ERROR As Single <o:p></o:p>
<o:p></o:p>
X_ERROR = [C2]<o:p></o:p>
<o:p></o:p>
ActiveWorkbook.Names.Add Name:="y_error_2", RefersToR1C1:="=Sheet1!R2C4:R11C4"<o:p></o:p>
<o:p></o:p>
ActiveSheet.ChartObjects("Chart 1").Activate<o:p></o:p>
ActiveChart.SeriesCollection(1).Select<o:p></o:p>
<o:p></o:p>
ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlX, Include:=xlMinusValues, Type:=xlFixedValue, Amount:=0
<o:p></o:p>
ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlX, Include:=xlPlusValues, Type:=xlFixedValue, Amount:=X_ERROR 'works!!<o:p></o:p>
<o:p></o:p>
ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlY, Include:=xlPlusValues, Type:=xlFixedValue, Amount:=0
<o:p></o:p>
ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlY, Include:=xlMinusValues, Type:=xlCustom, Amount:="=Sheet1!y_error_2" 'this line does not work under Excel 2007<o:p></o:p>
<o:p></o:p>
ActiveChart.SeriesCollection(1).ErrorBars.EndStyle = xlNoCap<o:p></o:p>
<o:p></o:p>
[A1].Select<o:p></o:p>
End Sub




Hope you can help me out. Thanks!

Geert<o:p></o:p>
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,215,106
Messages
6,123,124
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top