Hello,
I am working on a workbook where an on-page chart has to be updated depending on what the user wants to see displayed. I've attached an example of this workbook. The user would click one of the colored boxes on the left side of the page, and the means for that component, as well as means from previous periods of time would be displayed on the chart, along with the labels as to which variable they correspond with. The data and labels are being read from the second sheet in the workbook.
The data is being properly updated, but the labels do not change. If I check the data being read for the chart, it appears to be pulling over the correct labels, but unless I manually confirm the new labels, they are not displayed. The macro I am using works perfectly in Excel 2003, and was working just fine in 2007 until I copied the sheets (which I will need to do for the project I am working on).
The code is this:
Dim LabelRange As Range 'Range to hold labels for the chart
Dim CurrentRange As Range 'Range to hold current scores of questions
Dim OldRange1 As Range 'Range to hold old scores of questions (first time period back)
Dim OldRange2 As Range 'Range to hold old scores of questions (second time period back)
Sub ChangeQuestionScoreGraph()
ScoreSheet = ActiveSheet.Name
DataSheet = ActiveSheet.Next.Name
NamesSheet = ActiveSheet.Next.Next.Name
Application.ScreenUpdating = False
CompName = Application.Caller
Sheets(DataSheet).Activate
Range("A1").Select
Cells.Find(What:=CompName, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False).Activate
FirstRow = ActiveCell.Row
If ActiveCell.Offset(1) <> "" Then
Selection.End(xlDown).Select
End If
LastRow = ActiveCell.Row
Set LabelRange = Range("B" & FirstRow & ":B" & LastRow)
Set CurrentRange = Range("H" & FirstRow & ":H" & LastRow)
Set OldRange1 = Range("N" & FirstRow & ":N" & LastRow)
Set OldRange2 = Range("O" & FirstRow & ":O" & LastRow)
Sheets(NamesSheet).Activate
Range("A1").Select
Cells.Find(What:=CompName, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False).Activate
ThisChartTitle = ActiveCell.Offset(, 1)
Sheets(ScoreSheet).Activate
ActiveSheet.ChartObjects("ScoreChart1").Activate
ActiveChart.SeriesCollection(1).XValues = LabelRange
ActiveChart.SeriesCollection(1).Values = OldRange2
ActiveChart.SeriesCollection(2).Values = OldRange1
ActiveChart.SeriesCollection(3).Values = CurrentRange
ActiveChart.ChartTitle.Text = ThisChartTitle
ActiveChart.Refresh
Range("A1").Select
Application.ScreenUpdating = True
End Sub
Is there any way to force an update of the labels? I would think .Refresh would do the trick, but no such luck.
Thank you for your help.
Bookmarks