Hello, I would like to ask how to execute a command after the "if-then" is fulfilled, or before the "if-then" is executed.
Here's the first condition:
I want this command to be executed in order,such as, after changing the area print then the next "exit for" command will work so that it does not coincide with the execution of the printarea change.
The second condition is almost the same as the first condition but I'm confused about how this command can read ahead without waiting for the .printpreview change, at
in this command if "C4" becomes N/A or other then the loop will stop, but when I run it this command always executes after .printpreview runs so I need to discard 1 paper containing the value N/A.
can both conditions of my question be solved? if possible please help me thank you.
VBA Code:
'jika mendeteksi N/A atau sejenisnya perintah akan berhenti
'If found #N/A or #REF or any error loop will stop to prevent loop printing even data already reach limit
If IsError(po.Range("C4")) Then Exit For
If IsError(po.Range("C18")) Then
po.PageSetup.PrintArea = "$B$1:$L$15"
Exit For
'Jika M4 lebih besar dari batas akhir (O6) maka perintah akan terhenti
'If m4 > than O6 then print area will change and stop the loop (THIS IS THE PROBLEM)
If po.Range("M4") + 2 > po.Range("O6") Then po.PageSetup.PrintArea = "$B$1:$L$43"
If po.Range("M3") + 3 > po.Range("O6") Then po.PageSetup.PrintArea = "$B$1:$L$29"
If po.Range("M2") + 4 > po.Range("O6") Then po.PageSetup.PrintArea = "$B$1:$L$15"
Here's the first condition:
VBA Code:
If po.Range("M4") + 2 > po.Range("O6") Then po.PageSetup.PrintArea = "$B$1:$L$43"
The second condition is almost the same as the first condition but I'm confused about how this command can read ahead without waiting for the .printpreview change, at
VBA Code:
If IsError(po.Range("C4")) Then Exit For
in this command if "C4" becomes N/A or other then the loop will stop, but when I run it this command always executes after .printpreview runs so I need to discard 1 paper containing the value N/A.
can both conditions of my question be solved? if possible please help me thank you.