和Excel函数date同样功能的VBA函数DateSerial用法
Sub 日期别()
On Error Resume Next
lastrow = Sheets("运营日报").Range("a1048576").End(xlUp).Row
lastday = VBA.Day(Sheets("运营日报").Range("a" & lastrow)) + 1
lastcolumn = Sheets("运营统计表").Range("ag3").End(xlToLeft).Column + 1
For daterow = lastcolumn To lastday
With Sheets("运营统计表")
Set d = CreateObject("scripting.dictionary")
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
Set d3 = CreateObject("scripting.dictionary")
Set d4 = CreateObject("scripting.dictionary")
arr = Sheets("运营日报").Range("a1:y" & lastrow)
For a = 4 To UBound(arr)
If VBA.Day(arr(a, 1)) = .Cells(2, daterow) Then
If Not d.exists(arr(a, 3)) Then '订单号的去重计数
d.Add arr(a, 3), ""
End If
If Not d1.exists(arr(a, 4)) Then '商户的去重计数
d1.Add arr(a, 4), ""
End If
If Not d2.exists(arr(a, 5)) Then 'B端门店数的去重计数
d2.Add arr(a, 5), ""
End If
If Sheets("运营日报").Range("o" & a) = "收空瓶" Then
If Not d3.exists(arr(a, 5)) Then '特殊门店去重计数
d3.Add arr(a, 5), ""
End If
d4(arr(a, 1)) = d4(arr(a, 1)) + arr(a, 8) '特殊业务件数的汇总求和
End If
End If
Next
cou = d.Count
cou1 = d1.Count
cou2 = d2.Count
cou3 = d3.Count
cou4 = d4.items
.Cells(3, daterow) = cou
.Cells(4, daterow) = cou1
.Cells(5, daterow) = cou2
.Cells(9, daterow) = cou3
.Cells(11, daterow) = cou4
d.RemoveAll
d1.RemoveAll
d2.RemoveAll
d3.RemoveAll
d4.RemoveAll
'--------------
With Sheets("运营日报")
dat = DateSerial(2018, VBA.Month(Sheets("运营日报").Range("a" & lastrow)), daterow - 1)
'vba.year,month,day,这些属性虽然要求填写date类型的值,但是填入文本型也是可以的。
'dateserial 属性可以是integer,这个长整型,可以是时间格式,可以是文本格式的数字,可以是数字格式的。
Sheets("运营统计表").Cells(6, daterow) = WorksheetFunction.SumIfs(.Range("h4:h" & lastrow), .Range("a4:a" & lastrow), _
dat)
Sheets("运营统计表").Cells(7, daterow) = WorksheetFunction.SumIfs(.Range("i4:i" & lastrow), .Range("a4:a" & lastrow), _
dat) / 1000
Sheets("运营统计表").Cells(8, daterow) = WorksheetFunction.SumIfs(.Range("j4:j" & lastrow), .Range("a4:a" & lastrow), _
dat)
Sheets("运营统计表").Cells(10, daterow) = Sheets("运营统计表").Cells(9, daterow) / Sheets("运营统计表").Cells(5, daterow)
Sheets("运营统计表").Cells(12, daterow) = Sheets("运营统计表").Cells(11, daterow) / Sheets("运营统计表").Cells(6, daterow)
Sheets("运营统计表").Cells(13, daterow) = WorksheetFunction.CountIfs(.Range("v4:v" & lastrow), "*异常", .Range("a4:a" & lastrow), _
dat)
Sheets("运营统计表").Cells(14, daterow) = Sheets("运营统计表").Cells(13, daterow) / Sheets("运营统计表").Cells(3, daterow)
Sheets("运营统计表").Cells(15, daterow) = WorksheetFunction.CountIfs(.Range("v4:v" & lastrow), "<>*订单超时异常*", .Range("a4:a" & lastrow), _
dat)
Sheets("运营统计表").Cells(16, daterow) = Sheets("运营统计表").Cells(15, daterow) / Sheets("运营统计表").Cells(3, daterow)
End With
'-------------
End With
Next
End Sub
和Excel函数date同样功能的VBA函数DateSerial用法的更多相关文章
- Excel函数——DATE、SUBSTITUTE、REPLACE、ISERROR、IFERROR
1.DATE DATE 函数返回表示特定日期的连续序列号.例如,公式 =DATE(2008,7,8) 返回 2008-7-8或39637,取决于单元格格式,但空单元格计算和默认为日期格式. DATE也 ...
- [No0000C1]Excel 删除空白行和空白列VBA代码
在exce中删除空行和空列的方法有很多,相对而言删除空行较为简单,只需进行筛选,将空白行筛选出来,删除即可,但要删除空列比较困难.因为你不能按列进行筛选删除.Excel中没有这个功能.当然你可以用另外 ...
- Excel催化剂开源第1波-自定义函数的源代码全公开
Excel催化剂插件从2018年1月1日开始运营,到今天刚好一周年,在过去一年时间里,感谢社区里的许多友人们的关心和鼓励,得以坚持下来,并收获一定的用户量和粉丝数和少量的经济收入回报和个人知名度的提升 ...
- Excel的内置功能,其实真的是够用了。(学习观)
很多人问我,学好Excel是不是要背好多函数,是不是要会写VBA代码? 我说,那得看你能放多少时间和精力在Excel上. Excel的内置功能,其实真的是够用了:觉得不够用的,花几十块钱买个插件,也差 ...
- 模拟实现SQL Server中的datepart(week,date)的功能
本文目录列表: 1.为什么要模拟实现datepart(week,date)的功能 2.具体实现思路 3.T-SQL代码实现逻辑 4.总结语 5.参考清单列表 1.为什么要模拟实现datepart( ...
- PHP中日期时间函数date()用法总结
date()是我们常用的一个日期时间函数,下面我来总结一下关于date()函数的各种形式的用法,有需要学习的朋友可参考. 格式化日期date() 函数的第一个参数规定了如何格式化日期/时间.它使用字母 ...
- Python实现EXCEL表格的排序功能
EXCEL的数值排序功能还是挺强大的,升序.降序,尤其自定义排序,能够对多个字段进行排序工作. 那么,在Python大法中,有没有这样强大的排序功能呢?答案是有的,而且本人觉得Python的排序功能, ...
- SQL Fundamentals || Single-Row Functions || 日期函数date functions
SQL Fundamentals || Oracle SQL语言 SQL Fundamentals: Using Single-Row Functions to Customize Output使 ...
- poi实现excel的导入导出功能
Java使用poi实现excel的导入导出功能: 工具类ExcelUtil,用于解析和初始化excel的数据:代码如下 package com.raycloud.kmmp.item.service.u ...
随机推荐
- ocaml学习
ocaml与haskell一样,是functional programming的代表. 对于有一定编程经验的人来说,入手一种新语言,最有效的方式就是开发一些实用的utility,因此top-level ...
- DQL 数据查询语言 show
2.show show databases; 查看所有的库 show tables; 查看当前库的所有的表 show tables from database; 查看指定的库下的所有表 show pr ...
- Java全栈,MySQL搞透,架构手到擒来,还有面试官搞不定?
五月最后一天啦,时间过得真快,做技术的难免做了几年就感觉很迷茫,那就需要多读点书,多学点技术才能有安全感. 栈长之前推荐过不少极客时间的课程,几乎每周都推荐一个,很多朋友评论说,课程太多学不过来,今天 ...
- 48-Ubuntu-系统信息-3-查看进程命令
序号 命令 作用 01 ps aux process status查看进程的详细状况 02 top 动态显示运行中的进程并且排序 03 kill [-9] 进程代号 终止指定代号的进程,-9表示强行 ...
- uoj#244. 【UER #7】短路
题目 orz myy 这个矩形对称的性质非常优美,所以我们只需要考虑一个\(\frac{1}{4}\)的矩阵,即一个倒三角形 现在我们要求的是从\((1,1)\)到三角形对边上每个点的最短路,不难发现 ...
- hdu6395 /// 分块矩阵快速幂
题目大意: F(1)=A, F(2)=B, F(i)=C*F(i-2)+D*F(i-1)+p/i(向下取整) 给定A B C D p n 求F(n) 构造 矩阵A * 矩阵B = ...
- 配置Cesium编译环境
1.安装node.js https://nodejs.org/en/ 2.配置node.js 在node.js安装目录下新建node_global.node_cache两个文件夹,并把node_glo ...
- H5调用百度地图导航
template <div class="map"> <div class="content_flex"><img src=&qu ...
- delphi xe10 蓝牙
//蓝牙 System.Bluetooth //单元中主要包含以下几个类 TBluetoothManager.TBluetoothDeviceList.TBluetoothAdapter.TBluet ...
- Oracle实现行转列+Mybatis
1.需求 报表需要动态展示某几个公司分别在几个月内销售额情况(前端表头月份是动态的,月时间段是前端参数来选择的,最大为12个月), 页面展示如下 Oracle数据库中数据如下: 可以看到一个公司的月份 ...