|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub test()
Dim ar, br, cr$(), i&, iPosRow&, dic As Object, vKey
Set dic = CreateObject("Scripting.Dictionary")
ar = Sheets(1).[A1].CurrentRegion
For i = 3 To UBound(ar)
If ar(i, 1) <> "" Then
vKey = Val(Left(ar(i, 2), 2)) & "月"
dic(vKey) = dic(vKey) & "," & i
End If
Next i
For Each vKey In dic.keys
br = Split(dic(vKey), ",")
ReDim cr(1 To 10 ^ 3, 1 To 1)
With Sheets(vKey)
For i = 1 To UBound(br)
Select Case i
Case Is = 1
iPosRow = 1
Case Is = 2
iPosRow = 8
Case Is = 3
iPosRow = 13
Case Is = 4
iPosRow = 20
End Select
cr(iPosRow, 1) = ar(Val(br(i)), 2)
Next i
.Cells.Clear
.[A1].Resize(22) = cr
End With
Next
Beep
End Sub |
|