Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1446|回复: 3

[已解决]数据不联动,错在哪???

[复制链接]
发表于 2012-11-12 15:22 | 显示全部楼层 |阅读模式
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i%, n%, pn, pi
Dim pt As PivotTable
On Error Resume Next
Application.EnableEvents = False
Application.ScreenUpdating = False
Set pt = Target.PivotTable
pi = pt.PageFields("姓名").CurrentPage
n = 查询.PivotTables.Count
   For i = 1 To n
      查询.PivotTables(i).PageFields("姓名").CurrentPage = pi
   Next i
   Application.EnableEvents = True
   Application.ScreenUpdating = True
End Sub
帮我改一下,谢谢!!!


最佳答案
2012-11-12 16:18

  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2. Dim i%, n%, pn, pi
  3. Dim pt As PivotTable
  4. On Error Resume Next
  5. Application.EnableEvents = False
  6. Application.ScreenUpdating = False
  7. Set pt = Target.PivotTable
  8. pi = pt.PageFields("姓名").CurrentPage
  9. n = Sheets("查询").PivotTables.Count
  10.    For i = 1 To n
  11.       Sheets("查询").PivotTables(i).PageFields("姓名").CurrentPage = pi
  12.    Next i
  13.    Application.EnableEvents = True
  14.    Application.ScreenUpdating = True
  15. End Sub
复制代码

联动.zip

512.82 KB, 下载次数: 10

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2012-11-12 16:17 | 显示全部楼层

  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2. Dim i%, n%, pn, pi
  3. Dim pt As PivotTable
  4. On Error Resume Next
  5. Application.EnableEvents = False
  6. Application.ScreenUpdating = False
  7. Set pt = Target.PivotTable
  8. pi = pt.PageFields("姓名").CurrentPage
  9. n = Sheets("查询").PivotTables.Count
  10.    For i = 1 To n
  11.       Sheets("查询").PivotTables(i).PageFields("姓名").CurrentPage = pi
  12.    Next i
  13.    Application.EnableEvents = True
  14.    Application.ScreenUpdating = True
  15. End Sub
复制代码
回复

使用道具 举报

发表于 2012-11-12 16:18 | 显示全部楼层    本楼为最佳答案   

  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2. Dim i%, n%, pn, pi
  3. Dim pt As PivotTable
  4. On Error Resume Next
  5. Application.EnableEvents = False
  6. Application.ScreenUpdating = False
  7. Set pt = Target.PivotTable
  8. pi = pt.PageFields("姓名").CurrentPage
  9. n = Sheets("查询").PivotTables.Count
  10.    For i = 1 To n
  11.       Sheets("查询").PivotTables(i).PageFields("姓名").CurrentPage = pi
  12.    Next i
  13.    Application.EnableEvents = True
  14.    Application.ScreenUpdating = True
  15. End Sub
复制代码
回复

使用道具 举报

 楼主| 发表于 2012-11-12 17:19 | 显示全部楼层
suye1010 发表于 2012-11-12 16:17

谢谢你的帮忙,谢谢!!!!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-17 05:23 , Processed in 0.276004 second(s), 9 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表