Forum Discussion
Celia9
Sep 19, 2022Brass Contributor
Loop a list based on condition and print
Hi all, I have done this once, but I cannot remake the situation, hope someone can help me. I need to print a number of reports with a specific execution date. (see file attached) That date ...
- Sep 20, 2022
Thank you. Here is a macro:
Sub PrintReports() Dim ws As Worksheet Dim wt As Worksheet Dim r As Long Application.ScreenUpdating = False Set ws = Worksheets("Sheet4") Set wt = Worksheets("Werkbon") r = 3 Do While ws.Range("A" & r).Value <> "" wt.Range("B5").Value = "'" & ws.Range("A" & r).Value wt.PrintOut r = r + 1 Loop Application.ScreenUpdating = True End Sub
Celia9
Sep 20, 2022Brass Contributor
HansVogelaar Here it is 🙂
HansVogelaar
Sep 20, 2022MVP
Thank you. Here is a macro:
Sub PrintReports()
Dim ws As Worksheet
Dim wt As Worksheet
Dim r As Long
Application.ScreenUpdating = False
Set ws = Worksheets("Sheet4")
Set wt = Worksheets("Werkbon")
r = 3
Do While ws.Range("A" & r).Value <> ""
wt.Range("B5").Value = "'" & ws.Range("A" & r).Value
wt.PrintOut
r = r + 1
Loop
Application.ScreenUpdating = True
End Sub
- Celia9Sep 30, 2022Brass ContributorHi Hans,
Soms heeft een cel in de "A" range een nul, soms is het ""
Hoe kan ik ze allebei uitsluiten? Dus alleen printen als het niet 0 en niet "" is?- HansVogelaarSep 30, 2022MVP
Do While ws.Range("A" & r).Value <> "" And ws.Range("A" & r).Value <> 0
- Celia9Sep 21, 2022Brass ContributorYou are amazing Hans!