Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Range Object Question and Help Needed

Status
Not open for further replies.

kylegjordan

Technical User
Aug 1, 2001
8
US
When a range object is created and it refers to cells on a worksheet, can it be used as the values for a data series in a chart that is its own separate sheet?

Below is a section of a sub I'm trying to debug. The purpose is to add a new data series to the chart entitled "Consolidated" using a range of cells from a worksheet called "Weekly Tracker". Any help or suggested alternate routes would be great. Thanks. kj

Private Sub trialstuff()
Dim col(1 To 3) As Integer
Dim salesrow(1 To 2) As Integer
Dim datarange As Range, vari As Range, fari As Range
salesrow(2) = 37
col(3) = 47
j = 2
k = 3
Set vari = Worksheets("Weekly Tracker").Cells(salesrow(j), col(k))
Set fari = Worksheets("Weekly Tracker").Range("GA45:GD45")
Set datarange = Union(fari, vari)
Charts("Consolidated").SeriesCollection.NewSeries
Charts("Consolidated").SeriesCollection(k).Values = datarange
End Sub
 
I tried your code and it stopped when the Values property was assigned. It seems to be OK if there is only 1 area in the range i.e. not a union of two ranges.

Try using:

Charts("Consolidated").SeriesCollection.Add Source:=datarange

instead of the .NewSeries method and .Values property.

M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top