当前位置:网站首页>Excel VBA: summarize calculation output results by date (SUMIF)
Excel VBA: summarize calculation output results by date (SUMIF)
2022-07-26 05:03:00 【Avasla】
Problem scenario
1) By date C Amount listed Cumulative Summary
2) By date and " spending / income " Summarize daily amount
PS: Direct output , You don't need a formula 
Parameters are defined & Function description
Parameters are defined :
- Range Format definition summary range
- Long Format definition parameters . Because the length of subsequent parameters will exceed 32767, So choose Long.
- Long( Long integer ) Variables are stored as signed 32 position (4 byte ) Numbers , Values range from -2,147,483,648 To 2,147,483,647.
- Integer( plastic )Integer Variables are stored as 16 position (2 byte ) Numbers , The value range is -32,768 to 32,767.
Function USES :
- WorksheetFunction.Round (expression, [ numdecimalplaces ])
- WorksheetFunction.SumIfs (Arg1、Arg2、Arg3…)
1) Result code : Daily cumulative summary amount
Sub Daily cumulative summary amount ()
Application.ScreenUpdating = False
Dim sumRange As Range
Dim criteriaRange_date As Range
Dim e As Long, f As Long, g As Long
' Definition Range
Set sumRange = Sheets("Sheet1").Range("C2:C31") ' amount of money
Set criteriaRange_date = Sheets("Sheet1").Range("A2:A31") ' date
Sheets("Sheet1").Select
e = Range("K1048573").End(xlUp).Row ' Initial number of rows - 1
f = Range("J1048573").End(xlUp).Row ' Number of end lines
' to update
For g = e + 1 To f
' Cumulative
Sheets("Sheet1").Cells(g, 11) = WorksheetFunction.Round(WorksheetFunction.SumIfs(sumRange, criteriaRange_date, "<=" & Cells(g, 10)), 2)
Next g
End Sub
2) Result code : Daily expenditure income amount
Sub Daily expenditure income amount ()
Application.ScreenUpdating = False
Dim sumRange As Range
Dim criteriaRange As Range
Dim criteriaRange_date As Range
Dim e As Long, f As Long, g As Long
' Definition Range
Set sumRange = Sheets("Sheet1").Range("C2:C31") ' amount of money
Set criteriaRange = Sheets("Sheet1").Range("D2:D31") ' classification
Set criteriaRange_date = Sheets("Sheet1").Range("A2:A31") ' date
Sheets("Sheet1").Select
e = Range("O1048573").End(xlUp).Row ' Initial number of rows - 1
f = Range("N1048573").End(xlUp).Row ' Number of end lines
' to update
For g = e + 1 To f
' Cumulative
Sheets("Sheet1").Cells(g, 15) = WorksheetFunction.Round(WorksheetFunction.SumIfs(sumRange, criteriaRange, Cells(g, 14), criteriaRange_date, "=" & Cells(g, 13)), 2)
Next g
End Sub
Results after operation :

边栏推荐
- STM32 development | ad7606 parallel multi-channel data acquisition
- 迁移服务器,重新配置数据库(数据库无监听,启动监听报TNS-12545、TNS-12560、TNS-00515错误)
- [cloud native | 17] four network modes of container
- What are the well-known to-do apps at home and abroad
- SWAT模型在水文水资源、面源污染模拟中的实践技术
- The pit of history can only be filled up as far as possible
- MySQL eight knowledge points: from getting started to deleting the database
- Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!
- security权限管理详解
- Unnamed Article 33
猜你喜欢

Nacos 介绍和部署

推荐12个免费查找文献的学术网站,建议点赞、收藏!

基于R语言的Meta分析【全流程、不确定性分析】方法与Meta机器学习

Principle of image nonlocal mean filtering

Annotation @autowired how to assemble automatically

IEC61131 数据类型与 C#数据类型的对应

新导则下的防洪评价报告编制方法及洪水建模

Switch to router technology: OSPF single zone configuration, OSPF multi zone and end zone

五个维度着手MySQL的优化,我和面试官都聊嗨了

Tonight! Stonedb is officially open source. Please check this strategy~
随机推荐
LeetCode - 单调栈与单调队列
公交站间的距离 : 简单模拟题
异步时父子线程间的ThreadLocal传递问题
[mathematical modeling] basic knowledge of MATLAB
There was an unexpected error (type=Method Not Allowed, status=405).记录报错
webassembly 01基本资料
MySQL基础学习
minipcie接口CAN卡解决工控机扩展CAN通道的难题 minipcie CAN
mysql函数汇总之日期和时间函数
What are the demand management software for small and medium-sized enterprises
Character function and string function (I)
JVM第六讲:线上环境 FGC 频繁,如何解决?
Briefly describe the application fields of WMS warehouse management system
【云原生 | 17】容器的四种网络模式
Correspondence between IEC61131 data type and C data type
Batch convert ppm format pictures to JPG format
[enterprise micro procedure]
[weekly translation go] how to write your first program with go
Axi protocol (5): burst mechanism of Axi protocol
uniapp小程序框架-一套代码,多段覆盖