Option
Explicit
Sub
LieferscheineDrucken()
Dim
HPB
As
HPageBreak
Dim
breakAdress
As
Integer
Dim
pageNumber
As
Integer
Dim
productNumber
As
Integer
Dim
printCondition
As
Boolean
pageNumber = 1
printCondition =
False
For
productNumber = 10
To
61
ActiveSheet.Cells(productNumber,
"C"
).
Select
If
ActiveSheet.Cells(productNumber,
"C"
).Value <>
""
Then
printCondition =
True
End
If
Next
If
printCondition =
True
Then
ActiveSheet.PrintOut From:=1,
To
:=1, Copies:=1, Collate:=
True
End
If
printCondition =
False
pageNumber = pageNumber + 1
For
Each
HPB
In
ActiveSheet.HPageBreaks
breakAdress =
CInt
(Mid(HPB.Location.Address, 4, 5))
For
productNumber = (breakAdress + 9)
To
(breakAdress + 60)
If
ActiveSheet.Cells(productNumber,
"C"
).Value <>
""
Then
printCondition =
True
End
If
Next
If
printCondition =
True
Then
ActiveSheet.PrintOut From:=pageNumber,
To
:=pageNumber, Copies:=1, Collate:=
True
End
If
pageNumber = pageNumber + 1
printCondition =
False
Next
End
Sub