![]() |
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. |
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. |
All times are GMT +1. The time now is 08:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com