ThomasFoege
asked on
Graphs not updating from VBA run code from other sheet
Hello EE!
I have a Sheet1 containing a pivot slicer and a graph
While I in sheet2 have the actual pivot
In Sheet2, under a
What does not seem to work though, is this module:
I'm then using
DoGraph "Sheet1", "name of graph", "1", XValues, YValues
The slicer, the pivot, the module and the call of the module all worked when it was done in one sheet. However after I moved the pivot to sheet 2, it suddenly does not update the graph.
Is this a restriction in Excel or did my DoGraph break when i started adding Worksheet(TheSheet) instead of the previous Me?
I have a Sheet1 containing a pivot slicer and a graph
While I in sheet2 have the actual pivot
In Sheet2, under a
Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
It calculates data for a graph based on the pivot data. This I've checked to work.What does not seem to work though, is this module:
Sub DoGraph(TheSheet As String, TheChart As String, TheSeries As Integer, XValues As Variant, YValues As Variant)
With Worksheets(TheSheet).ChartObjects(TheChart).Chart
With .SeriesCollection(TheSeries)
.XValues = XValues
.Values = YValues
End With
End With
End Sub
I'm then using
DoGraph "Sheet1", "name of graph", "1", XValues, YValues
The slicer, the pivot, the module and the call of the module all worked when it was done in one sheet. However after I moved the pivot to sheet 2, it suddenly does not update the graph.
Is this a restriction in Excel or did my DoGraph break when i started adding Worksheet(TheSheet) instead of the previous Me?
Are you sure you are passing the right values? Also, are you getting an error, or simply nothing happening? (sample workbook might help)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm then using
DoGraph "Sheet1", "name of graph", "1", XValues, YValues
Try removing the quotes surrounding "1" in your parameters... the argument type shows it should be an Integer not a string.
Not sure if this is all that is wrong, but it's a start!
Glad you found a fix!
ASKER
Found the problem