PC Review


Reply
Thread Tools Rate Thread

Chart with a defined named range?

 
 
Matt S
Guest
Posts: n/a
 
      12th Sep 2008
I have a few ranges that are named within Excel. I'd like to chart my
Beginning_Timer range against my Temp_Ramp range with a XY Scatter plot.

If I put ActiveChart.SeriesCollection(1).XValues = "=Beginning_Timer"
it gives me an error '91' Object variable or With Block variable not set.

Help?
<3 Matt
 
Reply With Quote
 
 
 
 
scattered
Guest
Posts: n/a
 
      12th Sep 2008
On Sep 12, 11:15*am, Matt S <Ma...@discussions.microsoft.com> wrote:
> I have a few ranges that are named within Excel. *I'd like to chart my
> Beginning_Timer range against my Temp_Ramp range with a XY Scatter plot.
>
> If I put * * ActiveChart.SeriesCollection(1).XValues = "=Beginning_Timer"
> it gives me an error '91' Object variable or With Block variable not set.
>
> Help?
> <3 Matt


Maybe try ActiveChart.SeriesCollection(1).XValues =
Range("Beginning_Timer")

 
Reply With Quote
 
scattered
Guest
Posts: n/a
 
      12th Sep 2008
On Sep 12, 12:05*pm, scattered <former_schiz...@hotmail.com> wrote:
> On Sep 12, 11:15*am, Matt S <Ma...@discussions.microsoft.com> wrote:
>
> > I have a few ranges that are named within Excel. *I'd like to chart my
> > Beginning_Timer range against my Temp_Ramp range with a XY Scatter plot..

>
> > If I put * * ActiveChart.SeriesCollection(1).XValues = "=Beginning_Timer"
> > it gives me an error '91' Object variable or With Block variable not set.

>
> > Help?
> > <3 Matt

>
> Maybe try *ActiveChart.SeriesCollection(1).XValues =
> Range("Beginning_Timer")


The problem with my suggestion (assuming it would work) is that the
chart would be fixed to the current mening of the name
"Beginning_Timer". It wouldn't update automatically if the name
changes its reference. To get around this, it seems that (according to
the macro recorder) you need to give a fully-qualified name for the
series. If your workbook is called (say) Times.xls then try:

ActiveChart.SeriesCollection(1).XValues = "=Timer!Beginning_Timer"

hth

-scattered


 
Reply With Quote
 
Matt S
Guest
Posts: n/a
 
      12th Sep 2008
No such luck.

"scattered" wrote:

> On Sep 12, 11:15 am, Matt S <Ma...@discussions.microsoft.com> wrote:
> > I have a few ranges that are named within Excel. I'd like to chart my
> > Beginning_Timer range against my Temp_Ramp range with a XY Scatter plot.
> >
> > If I put ActiveChart.SeriesCollection(1).XValues = "=Beginning_Timer"
> > it gives me an error '91' Object variable or With Block variable not set.
> >
> > Help?
> > <3 Matt

>
> Maybe try ActiveChart.SeriesCollection(1).XValues =
> Range("Beginning_Timer")
>
>

 
Reply With Quote
 
scattered
Guest
Posts: n/a
 
      12th Sep 2008
On Sep 12, 12:31*pm, Matt S <Ma...@discussions.microsoft.com> wrote:
> No such luck.
>
>
>
> "scattered" wrote:
> > On Sep 12, 11:15 am, Matt S <Ma...@discussions.microsoft.com> wrote:
> > > I have a few ranges that are named within Excel. *I'd like to chartmy
> > > Beginning_Timer range against my Temp_Ramp range with a XY Scatter plot.

>
> > > If I put * * ActiveChart.SeriesCollection(1).XValues = "=Beginning_Timer"
> > > it gives me an error '91' Object variable or With Block variable not set.

>
> > > Help?
> > > <3 Matt

>
> > Maybe try *ActiveChart.SeriesCollection(1).XValues =
> > Range("Beginning_Timer")- Hide quoted text -

>
> - Show quoted text -


maybe try

Set ActiveChart.SeriesCollection(1).XValues = "=Timer!
Beginning_Timer"

Including the "Set" keyword in an assignment often takes care of error
91
 
Reply With Quote
 
Matt S
Guest
Posts: n/a
 
      12th Sep 2008
Scattered,

I've tried your suggestions and they have not worked.

Thanks,
Matt

"scattered" wrote:

> On Sep 12, 12:05 pm, scattered <former_schiz...@hotmail.com> wrote:
> > On Sep 12, 11:15 am, Matt S <Ma...@discussions.microsoft.com> wrote:
> >
> > > I have a few ranges that are named within Excel. I'd like to chart my
> > > Beginning_Timer range against my Temp_Ramp range with a XY Scatter plot..

> >
> > > If I put ActiveChart.SeriesCollection(1).XValues = "=Beginning_Timer"
> > > it gives me an error '91' Object variable or With Block variable not set.

> >
> > > Help?
> > > <3 Matt

> >
> > Maybe try ActiveChart.SeriesCollection(1).XValues =
> > Range("Beginning_Timer")

>
> The problem with my suggestion (assuming it would work) is that the
> chart would be fixed to the current mening of the name
> "Beginning_Timer". It wouldn't update automatically if the name
> changes its reference. To get around this, it seems that (according to
> the macro recorder) you need to give a fully-qualified name for the
> series. If your workbook is called (say) Times.xls then try:
>
> ActiveChart.SeriesCollection(1).XValues = "=Timer!Beginning_Timer"
>
> hth
>
> -scattered
>
>
>

 
Reply With Quote
 
scattered
Guest
Posts: n/a
 
      12th Sep 2008
On Sep 12, 1:07*pm, Matt S <Ma...@discussions.microsoft.com> wrote:
> Scattered,
>
> I've tried your suggestions and they have not worked.
>
> Thanks,
> Matt
>
>
>
> "scattered" wrote:
> > On Sep 12, 12:05 pm, scattered <former_schiz...@hotmail.com> wrote:
> > > On Sep 12, 11:15 am, Matt S <Ma...@discussions.microsoft.com> wrote:

>
> > > > I have a few ranges that are named within Excel. *I'd like to chart my
> > > > Beginning_Timer range against my Temp_Ramp range with a XY Scatter plot..

>
> > > > If I put * * ActiveChart.SeriesCollection(1).XValues = "=Beginning_Timer"
> > > > it gives me an error '91' Object variable or With Block variable not set.

>
> > > > Help?
> > > > <3 Matt

>
> > > Maybe try *ActiveChart.SeriesCollection(1).XValues =
> > > Range("Beginning_Timer")

>
> > The problem with my suggestion (assuming it would work) is that the
> > chart would be fixed to the current mening of the name
> > "Beginning_Timer". It wouldn't update automatically if the name
> > changes its reference. To get around this, it seems that (according to
> > the macro recorder) you need to give a fully-qualified name for the
> > series. If your workbook is called (say) Times.xls then try:

>
> > ActiveChart.SeriesCollection(1).XValues = "=Timer!Beginning_Timer"

>
> > hth

>
> > -scattered- Hide quoted text -

>
> - Show quoted text -


Sorry that they are not working. I am a bit confused - I was sure my
second post would work. I just created a workbook with a scatter chart
in it with x,y values inititialized in some random way. Then I created
2 named ranges. The following code works for me:

Sub Test()
Dim sh As Worksheet
Set sh = ActiveSheet
sh.ChartObjects(1).Activate
ActiveChart.SeriesCollection(1).XValues = "=Book1!Beginning_Timer"
ActiveChart.SeriesCollection(1).Values = "=Book1!Temp_Range"

End Sub

After running it, the chart's xvalues and yvalues point to the right
named range. Perhaps you could post more of your code.

As a suggestion, you could also experiment with eliminating things
like "ActiveChart" from your code. Try something like

Sub Test()
Dim sh As Worksheet
Dim ch As Chart
Dim mySeries As Series
Set sh = ActiveSheet
Set ch = sh.ChartObjects(1).Chart
Set mySeries = ch.SeriesCollection(1)
With mySeries
.XValues = "=Book1!Beginning_Timer"
.Values = "=Book1!Temp_Range"
End With
End Sub

A bit more verbose, but then you can use intellisense to ultimately
save on typing (in a larger program) and more importantly to help you
know if you are using the Excel object model correctly.

hth

-scattered
 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      12th Sep 2008
Your error description suggests you are running the code without actually
selecting a chart, or maybe you've just created a chart that doesn't yet
have a series. Beyond that the the syntax is not quite right

s = "='" & ActiveWorkbook.Name & "'!" & "Beginning_Timer"
s = "=Beginning_Timer"
ActiveChart.SeriesCollection(1).XValues = s

Obviously ensure a chart is active. Presumably the defined name is in the
same workbook, otherwise change ActiveWorkbook.Name to "myBook.xls" But if
working with a worksheet (local) name change use sheet-name.

Regards,
Peter T






"Matt S" <(E-Mail Removed)> wrote in message
news:AE29AFAB-13DF-4AC8-B390-(E-Mail Removed)...
>I have a few ranges that are named within Excel. I'd like to chart my
> Beginning_Timer range against my Temp_Ramp range with a XY Scatter plot.
>
> If I put ActiveChart.SeriesCollection(1).XValues = "=Beginning_Timer"
> it gives me an error '91' Object variable or With Block variable not set.
>
> Help?
> <3 Matt



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      13th Sep 2008
Use the name of the sheet that holds the name, and use syntax like this:

ActiveChart.SeriesCollection(1).XValues = "='" & ActiveSheet.Name &
"'!TheRange"

Excel will fill in the appropriate local or global scope for the name

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Peter T" <peter_t@discussions> wrote in message
news:(E-Mail Removed)...
> Your error description suggests you are running the code without actually
> selecting a chart, or maybe you've just created a chart that doesn't yet
> have a series. Beyond that the the syntax is not quite right
>
> s = "='" & ActiveWorkbook.Name & "'!" & "Beginning_Timer"
> s = "=Beginning_Timer"
> ActiveChart.SeriesCollection(1).XValues = s
>
> Obviously ensure a chart is active. Presumably the defined name is in the
> same workbook, otherwise change ActiveWorkbook.Name to "myBook.xls" But if
> working with a worksheet (local) name change use sheet-name.
>
> Regards,
> Peter T
>
>
>
>
>
>
> "Matt S" <(E-Mail Removed)> wrote in message
> news:AE29AFAB-13DF-4AC8-B390-(E-Mail Removed)...
>>I have a few ranges that are named within Excel. I'd like to chart my
>> Beginning_Timer range against my Temp_Ramp range with a XY Scatter plot.
>>
>> If I put ActiveChart.SeriesCollection(1).XValues = "=Beginning_Timer"
>> it gives me an error '91' Object variable or With Block variable not set.
>>
>> Help?
>> <3 Matt

>
>



 
Reply With Quote
 
Matt S
Guest
Posts: n/a
 
      15th Sep 2008
All,

Thanks so much for your suggestions. I still am receiving an error:
Run-time error '1004' Unable to set the XValues property of the Series class

Part of my range are empty cells... could this be the reason why?

Thanks,
Matt

"Jon Peltier" wrote:

> Use the name of the sheet that holds the name, and use syntax like this:
>
> ActiveChart.SeriesCollection(1).XValues = "='" & ActiveSheet.Name &
> "'!TheRange"
>
> Excel will fill in the appropriate local or global scope for the name
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> Peltier Technical Services, Inc. - http://PeltierTech.com
> _______
>
>
> "Peter T" <peter_t@discussions> wrote in message
> news:(E-Mail Removed)...
> > Your error description suggests you are running the code without actually
> > selecting a chart, or maybe you've just created a chart that doesn't yet
> > have a series. Beyond that the the syntax is not quite right
> >
> > s = "='" & ActiveWorkbook.Name & "'!" & "Beginning_Timer"
> > s = "=Beginning_Timer"
> > ActiveChart.SeriesCollection(1).XValues = s
> >
> > Obviously ensure a chart is active. Presumably the defined name is in the
> > same workbook, otherwise change ActiveWorkbook.Name to "myBook.xls" But if
> > working with a worksheet (local) name change use sheet-name.
> >
> > Regards,
> > Peter T
> >
> >
> >
> >
> >
> >
> > "Matt S" <(E-Mail Removed)> wrote in message
> > news:AE29AFAB-13DF-4AC8-B390-(E-Mail Removed)...
> >>I have a few ranges that are named within Excel. I'd like to chart my
> >> Beginning_Timer range against my Temp_Ramp range with a XY Scatter plot.
> >>
> >> If I put ActiveChart.SeriesCollection(1).XValues = "=Beginning_Timer"
> >> it gives me an error '91' Object variable or With Block variable not set.
> >>
> >> Help?
> >> <3 Matt

> >
> >

>
>
>

 
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
Linking a defined named range to Word vsoler Microsoft Excel Discussion 0 26th May 2008 11:14 AM
How to update a worksheet based on a defined named range using VB. Rambo Microsoft Excel Programming 0 23rd Mar 2008 07:32 AM
Defined named range (Array list) Sinner Microsoft Excel Programming 2 16th Feb 2008 02:17 PM
VBA defined named range not appearing in Names list... =?Utf-8?B?R2Vvcmdl?= Microsoft Excel Programming 13 15th Oct 2007 05:45 PM
Defined named range to array MattShoreson Microsoft Excel Programming 1 4th Dec 2003 10:06 AM


Features
 

Advertising
 

Newsgroups
 


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