自动数据透视表Refesh VBA代码。 [英] Automatic Pivot Table Refesh VBA code.

查看:329
本文介绍了自动数据透视表Refesh VBA代码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在使用excel模板自动刷新表excel。但我无法使它工作。当有人输入新数据时,您是否有任何VBa代码可以自动刷新整个数据透视表。希望您能帮助我。



最好的问候,

解决方案

您好
Thainguyens2k,


您曾问过,"您是否有任何VBa代码来制作当有人输入新数据时,整个数据透视表会自动刷新。"


请尝试参考下面的示例。

 Private Sub Worksheet_Change(ByVal Target As Range)
工作表("SheetName")。PivotTables("PivotTableName")。PivotCache.Refresh
End Sub

如果工作表中有多个数据透视表,那么您可以参考下面的代码来刷新它们。

 Private Sub Worksheet_Change(ByVal Target As Range)

Dim pt As PivotTable

For Each pt In Worksheets(" PivotTable")。PivotTables

pt.PivotCache.Refresh

Next


End Sub

参考:


PivotTable.RefreshTable Method(Excel)


问候


Deepak




Hi Guys,

I am working on excel template auto refresh table excel. but i am unable to make it work. Do you have any VBa code to make the whole pivot table refresh by itself automatically when someone input new data in. Hope you can help me out.

best Regards,

解决方案

Hi Thainguyens2k,

You had asked,"Do you have any VBa code to make the whole pivot table refresh by itself automatically when someone input new data in."

Please try to refer example below.

Private Sub Worksheet_Change(ByVal Target As Range)
    Worksheets("SheetName").PivotTables("PivotTableName").PivotCache.Refresh
End Sub

If you have multiple pivot tables in a sheet then you can refer code below to refresh them all.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim pt As PivotTable
 
 For Each pt In Worksheets("PivotTable").PivotTables

pt.PivotCache.Refresh

Next


End Sub

Reference:

PivotTable.RefreshTable Method (Excel)

Regards

Deepak


这篇关于自动数据透视表Refesh VBA代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆