98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Pivot Table Items - VBA (Anthony)
Pivot Table Items - VBA (Anthony)
Resolved · High Priority · Version 2010
Mark has attended:
Excel VBA Intro Intermediate course
Excel Advanced - For Power Users course
Excel PowerPivot course
Excel Dashboards for Business Intelligence course
Pivot Table Items - VBA (Anthony)
The item list for my Page items sometimes becomes corrupted. For example, when an entry in the item dropdown box is selected, the data that appears in the table is really for a different entry. This has happened several times, and the only way I have found to fix it is to rebuild the pivot table. This seems to happen at random, I am unable to trust the resulting output of the pivot table without verifying the output.
The Code iam Running on most of the pivot Tables is:
Application.ScreenUpdating = False
If Target.Address = Range("D3").Address Then
Me.PivotTables("PivotTable5").PivotFields("MA").CurrentPage = Range("D3").Value
Me.PivotTables("PivotTable6").PivotFields("MA").CurrentPage = Range("D3").Value
End If
If Target.Address = Range("D4").Address Then
Me.PivotTables("PivotTable5").PivotFields("FOM").CurrentPage = Range("D4").Value
Me.PivotTables("PivotTable6").PivotFields("FOM").CurrentPage = Range("D4").Value
End If
If Target.Address = Range("D5").Address Then
Me.PivotTables("PivotTable6").PivotFields("SITE").CurrentPage = Range("D5").Value
Me.PivotTables("PivotTable5").PivotFields("SITE").CurrentPage = Range("D5").Value
End If
End Sub
RE: Pivot Table Items - VBA (Anthony)
Hi Mark
Thanks for getting in touch.
Sounds like an odd issue, and they are always worse when they are intermittent. What about adding a refresh command to the end of your code, e.g.
ActiveWorkbook.RefreshAll
Kind regards
Gary Fenn
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Pivot Table Items - VBA (Anthony)
Hi Gary,
I've got a button that refreshes all of the pivot tables within the workbook so just to speed up the code however the problem still arises.
RE: Pivot Table Items - VBA (Anthony)
Hi Mark
Thanks for your reply. What is the drop-down you are using, is it a Form Control, Data Validation etc. ?
Kind regards
Gary Fenn
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Pivot Table Items - VBA (Anthony)
It's a Data Validation linked to the pivot via the VBA (code above).
RE: Pivot Table Items - VBA (Anthony)
Hi Mark
I notice you turn ScreenUpdating off, but it isn't turned back on again. This is notoriously unreliable at coming back itself, have you tried it with ScreenUpdating = True at the end?
Kind regards
Gary Fenn
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Pivot Table Items - VBA (Anthony)
Yes - The reason why is because it's attached to a separate button so it doesn't flash between screens when the entire database is updated.
RE: Pivot Table Items - VBA (Anthony)
Hi Mark
Thanks for your reply. Before we try anything else I'd like you to try adding Application.ScreenUpdating = False to the very last line of the last subroutine in the chain. Microsoft claim you don't need to add this line but there is a lot of evidence to suggest this does need to happen.
For belt and braces, I'd also recommend
Application.Calculate
in the same position, which will force Excel to recalculate the workbook.
Kind regards
Gary Fenn
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
Thu 10 Jan 2013: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Closing Multiple Open Worksheets At OnceWhen multiple Excel worksheets are opening, rather than performing a File > Close menu option multiple times, hold down the the SHIFT key and select the File > Close All menu option. |