• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help- automating with VBA

Pedrogf

New Member
Hello,

I need help with an huge amount of data that keep beeing refreshed. I need to develop a button that brings me the top 5 names that have the most sum amount of revenue and the sum of the amount of revenue of each name. thanks
 
If there's no need to get cute:
1) put your data in a dynamic named range
2) create 2 pivot tables with the desired sort on and set filter to top X
3) Using getpivotdata() set up grids on your output sheet
4) simple....super simple....vba to refresh the pivot tables based on the named range

Code:
Sub RefreshPivots()
Dim pt As PivotTable
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Sheets
    For Each pt In ws.PivotTables
        pt.RefreshTable
    Next pt
Next ws

       
End Sub
 

Attachments

  • vba.xlsm
    14.2 KB · Views: 2
Back
Top