Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default error when setting XValues for chart

Please help -- why do the last two lines cause Error 438 "Object
doesn't support this property or method"?

Dim rngXValues As Range, rngValues As Range
Set rngXValues = Range(Cells(12, 8).Cells, Cells(intLastRow, 8).Cells)
rngXValues.Select
Set rngValues = Range(Cells(12, intAskColumn).Cells, Cells(intLastRow,
intAskColumn).Cells)
rngValues.Select
Charts.Add
ActiveChart.Name = "MyChart"
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Data").rngValues,
PlotBy:=xlRows
ActiveChart.SeriesCollection(1).XValues = Worksheets("Data").rngXValues

The rng.Select statements work fine, so I know the ranges exist and are
correct. So what is the proper way to set the SourceData and XValues
properties? Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default error when setting XValues for chart

Use the Worksheet object when you set the ranges...
Set rngValues = Worksheets("Data").Range(Cells(12, intAskColumn), _
Cells(intLastRow, intAskColumn))
Then use the range object as the location...
ActiveChart.SetSourceData Source:=rngValues, PlotBy:=xlRows

If you have more than one sheet to reference, it is best to always
qualify ranges with the correct sheet.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



wrote in message
Please help -- why do the last two lines cause Error 438 "Object
doesn't support this property or method"?

Dim rngXValues As Range, rngValues As Range
Set rngXValues = Range(Cells(12, 8).Cells, Cells(intLastRow, 8).Cells)
rngXValues.Select
Set rngValues = Range(Cells(12, intAskColumn).Cells, Cells(intLastRow,
intAskColumn).Cells)
rngValues.Select
Charts.Add
ActiveChart.Name = "MyChart"
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Data").rngValues,
PlotBy:=xlRows
ActiveChart.SeriesCollection(1).XValues = Worksheets("Data").rngXValues

The rng.Select statements work fine, so I know the ranges exist and are
correct. So what is the proper way to set the SourceData and XValues
properties? Thanks.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
setting XValues property when charting using macros rhsiao Charts and Charting in Excel 3 April 7th 06 04:16 PM
error in XValues nanz Excel Programming 1 October 12th 05 11:02 PM
Error when setting chart Axis value Job Excel Programming 1 May 6th 05 04:04 PM
Setting chart series XValues in foreign language Gail Hurn Excel Programming 9 December 15th 04 09:47 AM
Chart Setting Xvalues Nigel[_8_] Excel Programming 1 December 24th 03 08:10 AM


All times are GMT +1. The time now is 03:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"