如何使用 VBA 从每日数据计算季度平均值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22695100/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 02:32:28  来源:igfitidea点击:

How to calculate quarterly averages from daily data with VBA?

excelvbaexcel-vba

提问by user137425

I have daily data from 01.01.1990. to 31.12.2012. I need to calculate quarterly averages from the daily data with a VBA function. Is there an efficient way to do this?

我有 1990 年 1 月 1 日的每日数据。到 31.12.2012。我需要使用 VBA 函数根据每日数据计算季度平均值。有没有一种有效的方法来做到这一点?

Any help is appreciated!

任何帮助表示赞赏!

回答by Brad

Put your data in a pivot table. Put your Date values in the Rows and put your numeric values in the Values. Right click on the date data and select Group...

将您的数据放入数据透视表中。将您的日期值放在行中,并将您的数值放在Values. 右键单击日期数据并选择Group...

Group by quarters/years

按季度/年分组

To make sure you are taking the average right click on your numeric data and select Value Field Settings

为了确保您对数字数据进行平均右键单击并选择 Value Field Settings

Value Field Settings-->Average

值字段设置-->平均值

You'll get something that looks like this

你会得到看起来像这样的东西

final output. quarters and group by year. show average.

最终输出。 季度和按年分组。 显示平均值。