新足迹

 找回密码
 注册

精华好帖回顾

· 隆重推出——京城回民小吃(面茶) (2005-7-25) binbingogo · Bennelong (2016-6-28) harbridge
· 澳洲银行最省钱方案完全评测报告(全) (2004-12-19) 飞龙 · 体育精神与素质教育 (2018-6-6) fhjp01
Advertisement
Advertisement
查看: 2038|回复: 7

[IT] Report Refresh Time-(Excel) [复制链接]

发表于 2013-1-25 22:18 |显示全部楼层
此文章由 平平淡淡 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 平平淡淡 所有!转贴必须注明作者、出处和本声明,并保持内容完整
本帖最后由 平平淡淡 于 2013-1-25 23:21 编辑

如果你经常用Excel通过数据库提取数据然后用PivotTable或PivotChart做一个Report,发给你经理希望每天打开这个Report就可以看到最新的数据。可以做如下操作:


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


Alt+F11 to open VBA window


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



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


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


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.



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.

希望对有需要的朋友有所帮助。








本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

评分

参与人数 2积分 +7 收起 理由
lazyvictor + 3 你太有才了
slau1 + 4 感谢分享

查看全部评分

Advertisement
Advertisement

发表于 2013-1-26 12:56 |显示全部楼层
此文章由 平平淡淡 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 平平淡淡 所有!转贴必须注明作者、出处和本声明,并保持内容完整
补充一点,或许有人会问为什么不用NOW()because it's volatile and it recalculates if you have other formulars in the same sheet.

评分

参与人数 1积分 +2 收起 理由
william.wangzy + 2 你太有才了

查看全部评分

发表于 2013-3-3 13:28 |显示全部楼层
此文章由 sinkingmoon 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 sinkingmoon 所有!转贴必须注明作者、出处和本声明,并保持内容完整
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

发表于 2014-9-19 14:58 |显示全部楼层
此文章由 1212qwe 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 1212qwe 所有!转贴必须注明作者、出处和本声明,并保持内容完整

发表于 2014-9-20 11:12 |显示全部楼层
此文章由 william.wangzy 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 william.wangzy 所有!转贴必须注明作者、出处和本声明,并保持内容完整
高手,mark

发表于 2014-9-20 12:27 |显示全部楼层
此文章由 心平气和 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 心平气和 所有!转贴必须注明作者、出处和本声明,并保持内容完整
Advertisement
Advertisement

发表于 2014-9-22 11:53 |显示全部楼层
此文章由 cllinzhen 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 cllinzhen 所有!转贴必须注明作者、出处和本声明,并保持内容完整
厉害

发表于 2015-2-19 14:18 |显示全部楼层
此文章由 wangxiaom 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 wangxiaom 所有!转贴必须注明作者、出处和本声明,并保持内容完整

发表回复

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

本版积分规则

Advertisement
Advertisement
返回顶部