updating pivot tables latest

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Updating Pivot Tables with latest data

Updating Pivot Tables with latest data

resolvedResolved · High Priority · Version 2010

Freddie has attended:
Excel VBA Introduction course

Updating Pivot Tables with latest data

Hi Guys


I'm trying to automatically update a pivot table by showing the latest source data (without the need to constantly keep selecting it). I have the below but it keeps falling over.

FileYear = Year(Date)
strFileMonth = Format(DateAdd("m", -1, Now), "YYYYMMDD")
FileDate = Format(Date - 1, "dd.mm.yyyy")
RateMonth = Format(Date - 1, "dd.mm.yyyy")

Sheets("PIVOT LDN").Select
ActiveSheet.PivotTables("PivotTable5").PivotSelect "", xlDataAndLabel, True
ActiveSheet.PivotTables("PivotTable5").PivotFields("FSDATE").CurrentPage = _
("ALL")
With ActiveSheet.PivotTables("PivotTable5").PivotFields("FSDATE")
.PivotItems("strFileMonth").Visible = True
End With
End Sub

Any advice on this?

Thanks

Freddie

RE: Updating Pivot Tables with latest data

Hi Freddie



Difficult to reproduce your question. Maybe send all the code or the workbook file to info@stl-training.co.uk


One thing to check. As strFileMonth is a variable I don't think it should have quotes around? See last line but one of your code.

Regards
Doug
Best STL

RE: Updating Pivot Tables with latest data

Hi Freddie


Thanks for sending your full code. For the part where you are filtering the pivot table (last 3 lines) try replacing with this

With ActiveSheet.PivotTables("PivotTable5").PivotFields("FSDATE")
.NumberFormat = "yyyymmdd"
.CurrentPage = strFileMonth
End With

Doug
Best STL

RE: Updating Pivot Tables with latest data

Hi Doug,

Apologies but when I run this I get a "Run time error 1004"

"Unable to set the NumberFormat property of the PivotField Class"

Are you able to advise?

Thanks

Freddie

 

Training courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Go to source of a cell

The default setting in Excel is when you double click in a cell it actives the formula in the cell. If you have created a link and want to directly go to that link (say if on another sheet, click on Tools -options and take off the tick for eidt it directly in cell

View all Excel hints and tips


Server loaded in 0.08 secs.