A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

error bars in VBA excel 2007 macro



 
 
Thread Tools Display Modes
  #1  
Old April 22nd, 2009, 05:58 AM posted to microsoft.public.excel.charting
Roland
external usenet poster
 
Posts: 74
Default error bars in VBA excel 2007 macro

I can't manage Y-error bars as the way it works in Excel 2000 VBA macro.
The macro stops and shows a run-time error 1004 at command;
ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlY, Include:= _
xlPlusValues, Type:=xlCustom, Amount:=4
What's different in Excel 2007 vs 2000 ?
  #2  
Old April 22nd, 2009, 12:16 PM posted to microsoft.public.excel.charting
Andy Pope
external usenet poster
 
Posts: 2,088
Default error bars in VBA excel 2007 macro

Hi,

You will need to change your code for xl2007.
If the Amount is fixed, in your case to the value 4, then you will need to
use the correct Type argument rather than custom.
If it is custom then you will need an array of values. And you will need
both plus and minus values even if the minus values are not used.

Sub xx()

Dim objSeries As Series
Dim vntArrayPlus() As Variant
Dim vntArrayMinus() As Variant
Dim lngIndex As Long

With ActiveChart.SeriesCollection(1)
ReDim vntArrayPlus(1 To .Points.Count)
ReDim vntArrayMinus(1 To .Points.Count)
For lngIndex = 1 To .Points.Count
vntArrayPlus(lngIndex) = 4
Next
.ErrorBar Direction:=XlErrorBarDirection.xlY, Include:=xlPlusValues,
_
Type:=xlErrorBarTypeCustom, Amount:=vntArrayPlus,
MinusValues:=vntArrayMinus

.ErrorBar Direction:=XlErrorBarDirection.xlY, Include:=xlPlusValues,
_
Type:=xlErrorBarTypeFixedValue, Amount:=4
End With


End Sub

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Roland" wrote in message
...
I can't manage Y-error bars as the way it works in Excel 2000 VBA macro.
The macro stops and shows a run-time error 1004 at command;
ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlY, Include:= _
xlPlusValues, Type:=xlCustom, Amount:=4
What's different in Excel 2007 vs 2000 ?


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.