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 19, 2022Brass Contributor
I made an extra step to ease up the process.
With a Index Small list I have made the list with workorders I want to print.
On worksheet Lijst, range A3:A40 I have the list.
I want to loop all the cells that <>""
(because I used the Index Small with IFERROR "")
With a Index Small list I have made the list with workorders I want to print.
On worksheet Lijst, range A3:A40 I have the list.
I want to loop all the cells that <>""
(because I used the Index Small with IFERROR "")
HansVogelaar
Sep 19, 2022MVP
Please attach the updated workbook.
- Celia9Sep 20, 2022Brass Contributor
HansVogelaar Here it is 🙂
- HansVogelaarSep 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?