Dim ta As Table = Tables("表A")
Dim tb As Table =Tables("表B") '默认类别列已经填写好1,2,3 ,其他的数据为0,且"数据类型为整型"
Dim lbm() As String = {"类别","一季度","二季度","三季度","四季度","本月"}
Dim lbh,jd As Integer '类别号 lbh获得1,2,3 jd为季度变量
Dim rq As Date '日期
Dim dy As Integer = Date.Today.Month '获得当前月份
Dim dr As Row
For Each r As Row In ta.Rows
lbh=r("第一列") '获得类别号 1,2,3
rq=r("第二列") '获得记录中的日期
jd=Int((rq.Month-1)/3)+1 '根据日期中的月份,转换成季度
dr=tb.Rows(lbh-1) '根据类别获得"表B"对应的行号 类别1对应0行,类别2对应1行
dr(lbm(jd))=dr(lbm(jd))+1 '根据指定单元格中的数量增加1
If rq.Month=dy Then
dr(lbm(5))=dr(lbm(5))+1
End If
Next
[此贴子已经被作者于2020/7/22 23:14:20编辑过]