和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 ...
随机推荐
- Lung Nodule Detection------work log
有时候真的不知道自己是怎么走上,模式识别,人工智能的这条路上的.但既然走上了这条路,我就没有理由荒废我所学到的东西.在学校里面研究了很长的时间的肺结节检测,但那都是只限于研究和写论文,现在我想把大家的 ...
- jenkins构建参数
$BUILD_NUMBER 构建序号 $WORKSPACE 工作目录 #!/bin/sh - chmod u+x mvnw./mvnw package -Pprod -Dmaven.test.skip ...
- 用户态和内核态&操作系统
用户态和内核态 内核态:cpu可以访问内存的所有数据,包括外围设备,例如硬盘,网卡,cpu也可以将自己从一个程序切换到另一个程序. 用户态:只能受限的访问内存,且不允许访问外围设备,占用cpu的能力被 ...
- touchWX使用 echarts
<button bindtap="init" wx:if="{{!isLoaded}}">加载图表</button> <butto ...
- mac下Python安装路径的说明
Python安装路径的说明 mac在安装Python时, 对不同的安装方式 不同的型号均会安装在不同的文件夹下 安装方式 路径 系统默认(2.7) /System/Library/Frameworks ...
- tp6 控制器不存在:app\index\controller\Index
tp6 控制器不存在:app\index\controller\Index config/app.php 修改如下 'auto_multi_app' => true,
- 结对编程UI
GitHub:https://github.com/zsl1996/UI/commits/master 一. 实验内容 这是交付给最终用户的软件,有一定的界面和必要的辅助功能.完 ...
- vagrant ssh try
Vagrantfile add Vagrant.configure("2") do |config| config.vm.network "private_network ...
- 关于使用vue-router的嵌套路由的命名路由时踩的坑
今天在做我的模仿微博项目时,我想实现点击router-link后,跳转到微博正文页面,并渲染其嵌套视图-评论组件.但是在实际实现时,我发现页面可以正常跳转,但是在页面加载后,并不渲染该页面的嵌套视图, ...
- 如何配置vue-cli4.0
这是一期主要分享vue-cli4.0配置 新建一个项目,最令人为难的是配置环境.拿vue来说,创建项目很简单,跟着文档走即可,但是要知道配置本地,测试,生产环境,以及反向代理等等,如果对于一个对vue ...