PDA

View Full Version : Range assignment in chart



Marco83
05-15-2008, 02:17 PM
Hello everyone.

I am having a problem trying to assign the X and Y values of a chart using the Range command.

What I want to accomplih is the following (obtained with MacroRecorder):

Sub RecChart()
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Calculations").Range("DA28")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=Calculations!R93C104:R94C104"

.
.
.

but instead than specifying the cells of interest as ..."=Calculations!R100C104:R101C104"..., I would like to use a statement similar to:

ActiveChart.SeriesCollection(1).XValues = Sheets("Calculations").Range(Cells(93, 104), Cells(94, 104))


I am a total beginner of VBA and I would appreciate having some help on this.

Thanks!

Bob Phillips
05-15-2008, 03:00 PM
.SeriesCollection(1).XValues = "=" & Sheets("Calculations").Range(Sheets("Calculations").Cells(93, 104), Sheets("Calculations").Cells(94, 104)).Address(True, True, xlR1C1, True)