Sub macro1()
On Error Resume Next
Dim a As Long, b As Long, i As Long, n As Long, arr()
a = Val(Replace(Replace([a2], "K", ""), "+", ""))
b = Val(Replace(Replace([B2], "K", ""), "+", ""))
n = (b - a + 20) \ 400
Application.ScreenUpdating = False
For i = 0 To n
[D1:H31].Copy Cells(31 * i + 1, 4)
ReDim arr(19, 0)
For J = 0 To 19
If a + i * 400 + J * 20 <= b Then arr(J, 0) = "K" & (a + i * 400 + J * 20) \ 1000 & "+" & Right("000" & (a + i * 400 + J * 20) Mod 1000, 3)
Next
[D8].Offset(31 * i, 0).Resize(20) = arr
Next
Application.ScreenUpdating = True
MsgBox "OK"
End Sub |