0

Hi, All:

I am getting crazy about this error. I tried everything but no help at all. Here is the simple task I want to do: adding a chart. The code is as below:

Charts.Add
ActiveChart.ChartType = xlXYScatterLines
Set myrange = Worksheets("Sheet1").Range("B16:B18")
ActiveChart.SetSourceData Source:=myrange, PlotBy:=xlColumns
ActiveChart.Location where:=xlLocationAsObject, Name:="Rates"

It always stops at line 3 and complaining about "Subscript out of range". But B16-B18 in sheet1 have data. Please anybody can help me? Thanks a lot!

3
Contributors
3
Replies
5
Views
9 Years
Discussion Span
Last Post by lhxndd
1

You have tried to activate the Source Data and assign it to the "myrange" array, but the "myrange" array is just the range only, it should there be VALUE of the range!

Votes + Comments
Rather late than never, thanks.:)
0

I'm sure the OP has found a solution since 2008, but no harm in adding an answer since there was no solution posted, thanks lhxndd.:)

0

I don't know whether or not yilin2008 could have found the solution for this, so I posted the solution for him!
Anyway, thanks everyone!

Do not hesitate to contact me and post question to daniweb.com. Thanks again!

My gmail is: [email snipped]

Edited by WaltP: Never post email messages on the forums

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.