Refresh data pada Pivot Table Macro Excel 2007

Barangkali kawan-kawan sudah biasa dengan namanya pemrograman macro pada excel, kali ini saya akan share mengenai cara mengupdate data pada pivot table. langsung saja cekidot..

'Refresh satu pivot Table pada sheet yang sedang aktif
Sub SinglePivot()
    Dim pt As PivotTable
    Set pt = ActiveSheet.PivotTables("PivotTable1")
    pt.RefreshTable
End Sub

'Refresh semua Pivot Tables pada  sheet yang sedang aktif
Sub AllWorksheetPivots()
    Dim pt As PivotTable
    For Each pt In ActiveSheet.PivotTables
        pt.RefreshTable
    Next pt
End Sub

'Refresh Pivot Tables tertentu pada sheet yang sedang aktif
Sub ChosenPivots()
    Dim pt As PivotTable
    For Each pt In ActiveSheet.PivotTables
        Select Case pt.Name
            Case "PivotTable1", "PivotTable4", "PivotTable8"
                .RefreshTable
            Case Else
        End Select
    Next pt
End Sub

'Refresh semua Pivot Tables pada seluruh Workbook
Sub AllWorkbookPivots()
    Dim pt As PivotTable
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
        For Each pt In ws.PivotTables
            pt.RefreshTable
        Next pt
    Next ws
End Sub

Selamat mencoba, semoga bermanfaat..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: