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用法的更多相关文章

  1. Excel函数——DATE、SUBSTITUTE、REPLACE、ISERROR、IFERROR

    1.DATE DATE 函数返回表示特定日期的连续序列号.例如,公式 =DATE(2008,7,8) 返回 2008-7-8或39637,取决于单元格格式,但空单元格计算和默认为日期格式. DATE也 ...

  2. [No0000C1]Excel 删除空白行和空白列VBA代码

    在exce中删除空行和空列的方法有很多,相对而言删除空行较为简单,只需进行筛选,将空白行筛选出来,删除即可,但要删除空列比较困难.因为你不能按列进行筛选删除.Excel中没有这个功能.当然你可以用另外 ...

  3. Excel催化剂开源第1波-自定义函数的源代码全公开

    Excel催化剂插件从2018年1月1日开始运营,到今天刚好一周年,在过去一年时间里,感谢社区里的许多友人们的关心和鼓励,得以坚持下来,并收获一定的用户量和粉丝数和少量的经济收入回报和个人知名度的提升 ...

  4. Excel的内置功能,其实真的是够用了。(学习观)

    很多人问我,学好Excel是不是要背好多函数,是不是要会写VBA代码? 我说,那得看你能放多少时间和精力在Excel上. Excel的内置功能,其实真的是够用了:觉得不够用的,花几十块钱买个插件,也差 ...

  5. 模拟实现SQL Server中的datepart(week,date)的功能

    本文目录列表: 1.为什么要模拟实现datepart(week,date)的功能 2.具体实现思路 3.T-SQL代码实现逻辑 4.总结语 5.参考清单列表   1.为什么要模拟实现datepart( ...

  6. PHP中日期时间函数date()用法总结

    date()是我们常用的一个日期时间函数,下面我来总结一下关于date()函数的各种形式的用法,有需要学习的朋友可参考. 格式化日期date() 函数的第一个参数规定了如何格式化日期/时间.它使用字母 ...

  7. Python实现EXCEL表格的排序功能

    EXCEL的数值排序功能还是挺强大的,升序.降序,尤其自定义排序,能够对多个字段进行排序工作. 那么,在Python大法中,有没有这样强大的排序功能呢?答案是有的,而且本人觉得Python的排序功能, ...

  8. SQL Fundamentals || Single-Row Functions || 日期函数date functions

    SQL Fundamentals || Oracle SQL语言   SQL Fundamentals: Using Single-Row Functions to Customize Output使 ...

  9. poi实现excel的导入导出功能

    Java使用poi实现excel的导入导出功能: 工具类ExcelUtil,用于解析和初始化excel的数据:代码如下 package com.raycloud.kmmp.item.service.u ...

随机推荐

  1. HDU 6590 Code (判断凸包相交)

    2019 杭电多校 1 1013 题目链接:HDU 6590 比赛链接:2019 Multi-University Training Contest 1 Problem Description Aft ...

  2. 拾遗:Go 基础

    这 Go,越看越像是 C 和 Python 的混合体--! gofmt 用于格式化代码,缩进使用 tab,而不是空格:Python 官方则建议使用空格,而不是 tab package Go 惯例,使用 ...

  3. mtk_Call setting(SS)

    1.SSDS: 2.PDN type 3.server回error之后的处理通过UT接口设置SS之后,网络有时候会回error,有些运营商会根据这些error来决定是否要CSFB, CSFB的条件如下 ...

  4. maven管理工具配置

    1.登录maven.apache.org,下载maven.,选择apache-maven-3.6.2-bin.zip,并解压到所需目录. 2.进行环境配置,计算机右击--属性---高级系统配置---环 ...

  5. 牛客练习赛51 B 子串查询 https://ac.nowcoder.com/acm/contest/1083/B

    题目描述 给出一个长度为n的字符串s和q个查询.对于每一个查询,会输入一个字符串t,你需要判断这个字符串t是不是s的子串.子串的定义就是存在任意下标a<b<c<d<e,那么”s ...

  6. Redis数据结构之整数集合-intset

    当一个集合只包含整数值元素,并且这个集合的元素数量不多时,Redis会使用整数集合(intset)来存储集合元素. intset是紧凑的数组结构,同时支持16位.32位和64位整数. 结构 struc ...

  7. nuxt 项目启动报错(HTMLElement is not define nuxt.js)

    这两天研究服务端渲染,折腾nuxt,搞得真是心累. 各种报错,nuxt 真是坑多啊,且来说说遇到哪些问题, 1. 搭建nuxt , npx create-nuxt-app <项目名> cd ...

  8. centos 7 中安装Oracle 12c

    今天有需要在centos 7上安装oracle 12 所以上网查了一下安装流程,原贴转自:https://blog.csdn.net/github_39294367/article/details/7 ...

  9. mysql组合查询

    使用UNION 多数SQL查询都只包含一个或多个表中返回数据的单条SELECT语句.MySQL也允许执行多个查询(多条SELECT语句),并将结果作为单个查询结果集返回.这些组合查询通常称为并(uni ...

  10. flink on yarn启动失败

    我启动hadoop on yarn 集群后 [root@node1 flink-1.6.1]# ./bin/yarn-session.sh -n 2 -jm 1024 -tm 1024 报的如下错误 ...