当前位置:网站首页>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 :

边栏推荐
- Axi protocol (5): burst mechanism of Axi protocol
- What points should be paid attention to in the selection of project management system?
- 基于通用优化软件GAMS的数学建模和优化分析
- [acwing] 2983. Toys
- Whether the SQL that fails to execute MySQL is counted into the slow query?
- Ggjj, do you have a look at this problem? Does caching cause cross domain problems?
- 阿里云工业视觉智能工程师ACP认证——备考
- [acwing] 1268. Simple questions
- 5个chrome简单实用的日常开发功能详解,赶快解锁让你提升更多效率!
- Character function and string function (I)
猜你喜欢

Switch and router technology: dynamic routing protocol, rip routing protocol and OSPF routing protocol

JVM Lecture 2: class loading mechanism

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

Excel VBA:实现自动下拉填充公式至最后一行

To study the trend of open source and gain insight into the future of the industry, stonedb community and the China Academy of communications and communications released the Research Report on the dev

Textfield and password input box that are more flexible and easy to use in compose

The integrated real-time HTAP database stonedb, how to replace MySQL and achieve nearly 100 times the improvement of analysis performance

Database startup message: ora-29702: error occurred in cluster group service

推荐12个免费查找文献的学术网站,建议点赞、收藏!
![[weekly translation go] how to write your first program with go](/img/77/cf77a46340a39797382fd7b60517d5.png)
[weekly translation go] how to write your first program with go
随机推荐
Bsdiff and bspatch incremental updates
关于负数表示的数值为什么比整数大1?
Vector explanation and iterator failure
AXI协议(4):AXI通道上的信号
手把手教你用代码实现SSO单点登录
【ACWing】2983. 玩具
BigDecimal 的 4 个坑,你踩过几个?
Alibaba three sides: how to solve the problems of MQ message loss, duplication and backlog?
面试之请详细说下synchronized的实现原理以及相关的锁
What are the well-known to-do apps at home and abroad
Whether the SQL that fails to execute MySQL is counted into the slow query?
uniapp小程序框架-一套代码,多段覆盖
@Principle of Autowired annotation
[cloud native | 17] four network modes of container
遥感、GIS和GPS技术在水文、气象、灾害、生态、环境及卫生等领域中的应用
滑动窗口——leetcode题解
How to connect tdengine through idea database management tool?
Building blocks for domestic databases, stonedb integrated real-time HTAP database is officially open source!
Mysql主从同步及主从同步延迟解决方案
提高shuffle操作中的reduce并行度