Option Explicit
Sub test2()
Dim ar, br, cr, i&, j&, r&, iPosRow&, m&, n&
Application.ScreenUpdating = False
ar = [G1:G3].Value
If ar(1, 1) = Empty Or ar(3, 1) = Empty Then Exit Sub
If ar(1, 1) > ar(3, 1) Then Exit Sub
br = Worksheets(2).[A1].CurrentRegion.Value
cr = [{"B1",3;"B2",4;"B3",5;"B4",6;"B5",7;"B6",8;"D1",9;"D2",10;"D3",11;"D4",12;"D5",13;"D6",14;"B7",15;"D7",16}]
For i = ar(1, 1) To ar(3, 1)
For j = 2 To UBound(br)
If br(j, 1) = i Then
Range("B5:B10,D5:E10,B17:B23,D17:E23,B29:B35,D29:E35").ClearContents
For m = 1 To 3
iPosRow = (m - 1) * 12 + 5
With Cells(iPosRow, 1)
For n = 1 To UBound(cr)
.Range(cr(n, 1)) = br(j, cr(n, 2))
Next n
End With
Next m
ActiveSheet.PrintOut
Exit For
End If
Next j
Next i
Application.ScreenUpdating = True
Beep
End Sub
|