PC Review


Reply
Thread Tools Rate Thread

chart error bars

 
 
Paula Galloway
Guest
Posts: n/a
 
      30th Mar 2009
Has anyone had success with creating custom error bars in Excel 2007 from VBA?

In prior versions I was able to do so with

ActiveChart.SeriesCollection(4).ErrorBar Direction:=xlY, Include:= _
xlPlusValues, Type:=xlCustom, Amount:="=MySheet!R2C17:R4C17"

When I try that code in 2007 I get error 1004, Application-defined or
object-defined error.
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      30th Mar 2009
How odd. It works fine but only if you do it like this

On Error Resume Next
' set the error bars
On Error Goto 0

Maybe one for Andy Pope !

Regards,
Peter T

"Paula Galloway" <(E-Mail Removed)> wrote in message
news:83B0AC88-15AE-41CB-A385-(E-Mail Removed)...
> Has anyone had success with creating custom error bars in Excel 2007 from
> VBA?
>
> In prior versions I was able to do so with
>
> ActiveChart.SeriesCollection(4).ErrorBar Direction:=xlY, Include:= _
> xlPlusValues, Type:=xlCustom, Amount:="=MySheet!R2C17:R4C17"
>
> When I try that code in 2007 I get error 1004, Application-defined or
> object-defined error.



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      30th Mar 2009
As I mentioned, the code worked for me under 'on error resume next'. However
to get it to work without forcing, it seems need to supply both error bars,
even if the minus are not required.

Set sr = ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1)
sr.ErrorBar Direction:=xlY, _
Include:=xlBoth, _
Type:=xlCustom, _
Amount:="=Sheet1!R2C17:R4C17", _
MinusValues:="={0}"

Could also do
Amount:=Range("$Q$2:$Q$4")

Note, in the above, chart, series index and sheet name changed from your
original.

Regards,
Peter T


"Peter T" <peter_t@discussions> wrote in message
news:(E-Mail Removed)...
> How odd. It works fine but only if you do it like this
>
> On Error Resume Next
> ' set the error bars
> On Error Goto 0
>
> Maybe one for Andy Pope !
>
> Regards,
> Peter T
>
> "Paula Galloway" <(E-Mail Removed)> wrote in
> message news:83B0AC88-15AE-41CB-A385-(E-Mail Removed)...
>> Has anyone had success with creating custom error bars in Excel 2007 from
>> VBA?
>>
>> In prior versions I was able to do so with
>>
>> ActiveChart.SeriesCollection(4).ErrorBar Direction:=xlY, Include:= _
>> xlPlusValues, Type:=xlCustom, Amount:="=MySheet!R2C17:R4C17"
>>
>> When I try that code in 2007 I get error 1004, Application-defined or
>> object-defined error.

>
>



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      1st Apr 2009
Peter -

You were right. Andy figured this one out for me some time ago, and it's now
part of my bag of tricks.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______


"Peter T" <peter_t@discussions> wrote in message
news:%(E-Mail Removed)...
> As I mentioned, the code worked for me under 'on error resume next'.
> However to get it to work without forcing, it seems need to supply both
> error bars, even if the minus are not required.
>
> Set sr = ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1)
> sr.ErrorBar Direction:=xlY, _
> Include:=xlBoth, _
> Type:=xlCustom, _
> Amount:="=Sheet1!R2C17:R4C17", _
> MinusValues:="={0}"
>
> Could also do
> Amount:=Range("$Q$2:$Q$4")
>
> Note, in the above, chart, series index and sheet name changed from your
> original.
>
> Regards,
> Peter T
>
>
> "Peter T" <peter_t@discussions> wrote in message
> news:(E-Mail Removed)...
>> How odd. It works fine but only if you do it like this
>>
>> On Error Resume Next
>> ' set the error bars
>> On Error Goto 0
>>
>> Maybe one for Andy Pope !
>>
>> Regards,
>> Peter T
>>
>> "Paula Galloway" <(E-Mail Removed)> wrote in
>> message news:83B0AC88-15AE-41CB-A385-(E-Mail Removed)...
>>> Has anyone had success with creating custom error bars in Excel 2007
>>> from VBA?
>>>
>>> In prior versions I was able to do so with
>>>
>>> ActiveChart.SeriesCollection(4).ErrorBar Direction:=xlY, Include:= _
>>> xlPlusValues, Type:=xlCustom, Amount:="=MySheet!R2C17:R4C17"
>>>
>>> When I try that code in 2007 I get error 1004, Application-defined or
>>> object-defined error.

>>
>>

>
>



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      1st Apr 2009
> Andy figured this one out for me some time ago

I should have guessed :-)

Regards,
Peter T


"Jon Peltier" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Peter -
>
> You were right. Andy figured this one out for me some time ago, and it's
> now part of my bag of tricks.
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Peltier Technical Services, Inc.
> http://PeltierTech.com/WordPress/
> _______
>
>
> "Peter T" <peter_t@discussions> wrote in message
> news:%(E-Mail Removed)...
>> As I mentioned, the code worked for me under 'on error resume next'.
>> However to get it to work without forcing, it seems need to supply both
>> error bars, even if the minus are not required.
>>
>> Set sr = ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1)
>> sr.ErrorBar Direction:=xlY, _
>> Include:=xlBoth, _
>> Type:=xlCustom, _
>> Amount:="=Sheet1!R2C17:R4C17", _
>> MinusValues:="={0}"
>>
>> Could also do
>> Amount:=Range("$Q$2:$Q$4")
>>
>> Note, in the above, chart, series index and sheet name changed from your
>> original.
>>
>> Regards,
>> Peter T
>>
>>
>> "Peter T" <peter_t@discussions> wrote in message
>> news:(E-Mail Removed)...
>>> How odd. It works fine but only if you do it like this
>>>
>>> On Error Resume Next
>>> ' set the error bars
>>> On Error Goto 0
>>>
>>> Maybe one for Andy Pope !
>>>
>>> Regards,
>>> Peter T
>>>
>>> "Paula Galloway" <(E-Mail Removed)> wrote in
>>> message news:83B0AC88-15AE-41CB-A385-(E-Mail Removed)...
>>>> Has anyone had success with creating custom error bars in Excel 2007
>>>> from VBA?
>>>>
>>>> In prior versions I was able to do so with
>>>>
>>>> ActiveChart.SeriesCollection(4).ErrorBar Direction:=xlY, Include:= _
>>>> xlPlusValues, Type:=xlCustom, Amount:="=MySheet!R2C17:R4C17"
>>>>
>>>> When I try that code in 2007 I get error 1004, Application-defined or
>>>> object-defined error.
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Paula Galloway
Guest
Posts: n/a
 
      7th Apr 2009
Thanks!

"Peter T" wrote:

> > Andy figured this one out for me some time ago

>
> I should have guessed :-)
>
> Regards,
> Peter T
>
>
> "Jon Peltier" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Peter -
> >
> > You were right. Andy figured this one out for me some time ago, and it's
> > now part of my bag of tricks.
> >
> > - Jon
> > -------
> > Jon Peltier, Microsoft Excel MVP
> > Peltier Technical Services, Inc.
> > http://PeltierTech.com/WordPress/
> > _______
> >
> >
> > "Peter T" <peter_t@discussions> wrote in message
> > news:%(E-Mail Removed)...
> >> As I mentioned, the code worked for me under 'on error resume next'.
> >> However to get it to work without forcing, it seems need to supply both
> >> error bars, even if the minus are not required.
> >>
> >> Set sr = ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1)
> >> sr.ErrorBar Direction:=xlY, _
> >> Include:=xlBoth, _
> >> Type:=xlCustom, _
> >> Amount:="=Sheet1!R2C17:R4C17", _
> >> MinusValues:="={0}"
> >>
> >> Could also do
> >> Amount:=Range("$Q$2:$Q$4")
> >>
> >> Note, in the above, chart, series index and sheet name changed from your
> >> original.
> >>
> >> Regards,
> >> Peter T
> >>
> >>
> >> "Peter T" <peter_t@discussions> wrote in message
> >> news:(E-Mail Removed)...
> >>> How odd. It works fine but only if you do it like this
> >>>
> >>> On Error Resume Next
> >>> ' set the error bars
> >>> On Error Goto 0
> >>>
> >>> Maybe one for Andy Pope !
> >>>
> >>> Regards,
> >>> Peter T
> >>>
> >>> "Paula Galloway" <(E-Mail Removed)> wrote in
> >>> message news:83B0AC88-15AE-41CB-A385-(E-Mail Removed)...
> >>>> Has anyone had success with creating custom error bars in Excel 2007
> >>>> from VBA?
> >>>>
> >>>> In prior versions I was able to do so with
> >>>>
> >>>> ActiveChart.SeriesCollection(4).ErrorBar Direction:=xlY, Include:= _
> >>>> xlPlusValues, Type:=xlCustom, Amount:="=MySheet!R2C17:R4C17"
> >>>>
> >>>> When I try that code in 2007 I get error 1004, Application-defined or
> >>>> object-defined error.
> >>>
> >>>
> >>
> >>

> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Customise error bars on individual bars in a bar chart 2007 Millie Microsoft Excel Charting 2 25th Apr 2009 04:16 AM
How to add error bars to 3-D chart =?Utf-8?B?U2hpamlh?= Microsoft Excel Misc 2 20th Nov 2007 09:48 PM
Colouring error bars in a chart Graham Whitehead Microsoft Excel Programming 1 4th Aug 2006 02:59 PM
Powerpoint 97 - Chart Error Bars TC Microsoft Powerpoint 1 21st Aug 2004 03:06 PM
Individual error bars on chart Paul N Microsoft Excel Worksheet Functions 0 26th Nov 2003 04:26 PM


Features
 

Advertising
 

Newsgroups
 


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