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

updating pivot tables latest

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

ResolvedVersion 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:

Percentage format

Ctrl+Shift+% applies the Percentage format, with no decimal places.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.14 secs.