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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on Chart Class

Status
Not open for further replies.

aMember

Programmer
Jun 12, 2002
99
US
I'm trying to redefine the 3 series of an embedded chart. At first, I did it without the use of a chart class. It worked most of the time time, but not always. So, thought I was missing something and tried to do it with a chart class.
Created a class module, named it PHChartClass. Entered the following code (yes, some routines are missing for sake of brevity):

Option Explicit
Option Compare Text
Public WithEvents PHChartClass As Chart

Private PHChart As Chart

Public Sub MoveSeries
Dim CPIRow
Dim DateRow
Dim theDates As Range
Dim DataSheet As Worksheet
Dim OldestMonth As Range
Dim NewestMonth As Range
Dim QCWindow As Range
Dim DateWindow As Range
Dim DataWindow As Range

CPIRow = Range("CPIData").Row
DateRow = Range("Date").Row
Set theDates = Range("Date")
Set DataSheet = Sheets("Data")
Set QCWindow = Sheets("QC").Range("TheWindow")
'Find the Oldest date in theDates
Set OldestMonth = FindOldestDate(QCWindow)
Set OldestMonth = LookupDate(OldestMonth.Value, DataSheet, DataSheet.Range("Date"))
If OldestMonth Is Nothing Then
MsgBox "Error updating PH chart"
GoTo Cleanup
End If

'Find the newest date in theDates
Set NewestMonth = FindNewestDate(QCWindow, DataSheet, OldestMonth.Column)

If IsEmpty(NewestMonth.Value) Then
'at the end of the visible list.
Exit Sub
End If

'Create a DateWindow that points to 6 columns of dates on the Data sheet
Set DateWindow = DataSheet.Range(OldestMonth.Address, NewestMonth.Address)

Set DataWindow = DateWindow.Offset(Sheets("Data").Range("CPIData").Row - 1)

PHChart.Activate Here is the problem. Object variable or with variable not set
'Set range for CPI
PHChart.SeriesCollection("CPI").Values = DataWindow
'Set Range for SPI
Set DataWindow = DateWindow.Offset(Sheets("Data").Range("SPIData").Row - 1)
PHChart.SeriesCollection("SPI").Values = DataWindow
'Set Range for BAC/EAC4
Set DataWindow = DateWindow.Offset(Sheets("Data").Range("BACEAC4").Row - 1)
PHChart.SeriesCollection("BAC/EAC4").Values = DataWindow
'Set Category labels
PHChart.SeriesCollection("BAC/EAC4").XValues = DateWindow

Sheets("QC").Range("h10").Select

Cleanup:
Set DataSheet = Nothing
Set QCWindow = Nothing
Set OldestMonth = Nothing
Set NewestMonth = Nothing

End Sub

------------
What am I doing wrong?
Any help greatly appreciated!
Andrea
 
I'm not very familiar with class modules, but have you tried

me.activate?

Rob
[flowerface]
 
Thanks Rob for the suggestion but that isn't it. Having gone back to the drawing board I've posted the question again with a lot more detail. If you have some time, could you take a look at it and tell me what you think? I've gone back to doing the chart without the class and I'm still having problems.

Thanks again,
Andrea
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top