官方微信 手机客户端

澳洲ABC

搜索
查看: 1453|回复: 8

[IT] Report Refresh Time-(Excel)

[复制链接]

3

主题

58

帖子

143

积分

正式会员

Rank: 2

积分
143
发表于 2014-10-7 14:03:45 | 显示全部楼层 |阅读模式
本帖最后由 平平淡淡 于 2013-1-25 23:21 编辑
如果你经常用Excel通过数据库提取数据然后用PivotTable或PivotChart做一个Report,发给你经理希望每天打开这个Report就可以看到最新的数据。可以做如下操作:

2013-1-25 22:57:12 上传
下载附件 (99.57 KB)

Click Data Tab then From Other Sources to choose your datasource to add PivotTable

2013-1-25 22:57:15 上传
下载附件 (76.16 KB)

Alt+F11 to open VBA window

2013-1-25 22:57:16 上传
下载附件 (62.37 KB)

Right Click any objects in project window and choose Insert the module

2013-1-25 23:05:00 上传
下载附件 (75.85 KB)

Paste the below code to create a user defined function
Function LastRefreshTime(Rng As Range) As Variant
Dim PT As PivotTable
Set PT = Rng.Cells.PivotTable
LastRefreshTime = PT.RefreshDate
End Function


2013-1-25 22:57:17 上传
下载附件 (73.94 KB)

Use the function.Note reference any cell in PivotTable, or function will return error.

2013-1-25 22:57:19 上传
下载附件 (168.23 KB)

It will return an number with decimal,but we want a time.Select the cell with fomular and press CTRL+1 to bring up FormatCell dialog box,click Number tab and click Custom and type "dd/mmm/yyy hh:mm" in "Type" field.

2013-1-25 22:57:20 上传
下载附件 (83.38 KB)

It now give us the date and time the report was refreshed. then add some text above the Pivottable to tell your boss he is looking at the lastest data. Finally click anywhere in the PivotTable report. This displays the PivotTable Tools, adding an Options and a Design tab. On the Options tab, in the PivotTable group, click Options. In the PivotTable Options dialog box, on the Data tab, select the Refresh data when opening the file check box. Every morning your boss open the file,the pivottable will automatically refresh to get the latest data.
希望对有需要的朋友有所帮助。




上一篇:我该如何是好啊?
下一篇:已经或计划在澳洲从事医师的朋友请进(AMC MCQ)

3

主题

58

帖子

143

积分

正式会员

Rank: 2

积分
143
发表于 2014-10-7 14:35:07 | 显示全部楼层

补充一点,或许有人会问为什么不用NOW()because it's volatile and it recalculates if you have other formulars in the same sheet.
回复 支持 反对

使用道具 举报

0

主题

7

帖子

23

积分

新手上路

Rank: 1

积分
23
发表于 2014-10-7 15:15:26 | 显示全部楼层

The function should have returned date type, instead of variant. Also the input variable probably is better to be pivot table names Such as pivottable as string
回复 支持 反对

使用道具 举报

0

主题

18

帖子

70

积分

新手上路

Rank: 1

积分
70
发表于 2014-10-7 16:18:05 | 显示全部楼层

高手,mark
回复 支持 反对

使用道具 举报

0

主题

16

帖子

52

积分

新手上路

Rank: 1

积分
52
发表于 2014-10-7 18:35:39 | 显示全部楼层

厉害
回复 支持 反对

使用道具 举报

0

主题

1万

帖子

1万

积分

江湖老手

Rank: 6Rank: 6

积分
11078
发表于 2015-7-11 03:16:51 | 显示全部楼层
帮你顶顶!!!
回复 支持 反对

使用道具 举报

6

主题

5742

帖子

5759

积分

江湖老手

Rank: 6Rank: 6

积分
5759
发表于 2015-8-1 05:05:34 | 显示全部楼层
帮你顶顶!!!
回复 支持 反对

使用道具 举报

9

主题

1万

帖子

1万

积分

江湖老手

Rank: 6Rank: 6

积分
11338
发表于 2015-8-28 05:14:49 | 显示全部楼层
好吧,
回复 支持 反对

使用道具 举报

12

主题

1万

帖子

1万

积分

江湖老手

Rank: 6Rank: 6

积分
11266
发表于 2015-12-1 05:23:19 | 显示全部楼层
好吧,
回复 支持 反对

使用道具 举报

发表回复

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

本版积分规则

联系客服 关注微信 下载APP 返回顶部 返回列表