|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub qs()
- Dim arr, i, sm, br, crr, r, m
- ny = Year(Sheet1.[a1]) & "年" & VBA.Month(Sheet1.[a1])
- br = [{4,8,12,16}]
- arr = Sheet1.Range("a1").CurrentRegion.Value
- ReDim crr(1 To UBound(arr), 1 To 7)
- For i = 3 To UBound(arr)
- m = 0
- For j = 1 To UBound(br)
- ny2 = Year(arr(i, br(j))) & "年" & Month(arr(i, br(j)))
- If ny = ny2 Then
- m = m + 1
- End If
- Next j
- If m = 4 Then
- sm = 0
- r = r + 1
- crr(r, 1) = arr(i, 1)
- For x = 1 To UBound(br)
- crr(r, x + 2) = arr(i, br(x) - 1)
- sm = sm + arr(i, br(x) - 1)
- Next
- crr(r, 2) = sm
- End If
- Next
- Sheet2.Range("a2").Resize(10000, 7).ClearContents
- Sheet2.Range("a2").Resize(r, 7) = crr
- End Sub
复制代码 |
|