Macro work in Excel 2003 but not Excel 2007

S

Shawn M.

This code works in Excel 2003, but gives me a Type Mismatch error in Excel
2007.

Sub aaa()

Dim submissionXValsRange
Set submissionXValsRange = Sheets("Sheet1").Range("A1:A5")

Dim submissionYValsRange
Set submissionYValsRange = Sheets("Sheet1").Range("B1:B5")

' Actual submission values scatter chart
Dim MyNewSrs As Series
Set MyNewSrs = Sheets("Chart1").SeriesCollection.NewSeries
With MyNewSrs
.Name = "Data"
.Values = submissionYValsRange
.XValues = submissionXValsRange
.Trendlines.Add Type:=xlLinear, Name:="Linear Trendline ",
Forward:=2000, DisplayEquation:=True
End With

End Sub
 
J

Jon Peltier

Declare your ranges 'As Range' and it will work.

That's kind of far to be extrapolating, isn't it?

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top