shapeshiftingkiwi
New Member
- Joined
- Mar 31, 2021
- Messages
- 33
- Office Version
- 365
- Platform
- Windows
I can't figure out why the Print_Only2 sub is running when the exit flags are being triggered. Also, what would be the proper logical operator to have Print_Only2 not run if ExitFlag1 is true OR ExitFlag2 is true, OR both are true?
Any help much appreciated, I feel like I'm close.
Any help much appreciated, I feel like I'm close.
VBA Code:
Public Sub Save_Then_Print()
Save_As5
If Exitflag1 = False Or Exitflag2 = False Then
Print_Only2
End If
End Sub
Private Sub Save_As5()
Dim Exitflag1 As Boolean, Exitflag2 As Boolean
Exitflag1 = False
Exitflag2 = False
Dim ErrorCells As String
ErrorCells = ""
For Each cell In ActiveSheet.Range("F14:F37")
If cell.EntireRow.Hidden = False And cell.value = "" Then
Exitflag1 = True
ErrorCells = ErrorCells & cell.Offset(0, -2).value & ", "
End If
Next cell
For Each cell In ActiveSheet.Range("G14:G16,G18:G37")
If cell.EntireRow.Hidden = False And cell.value = "" Then
Exitflag2 = True
ErrorCells = ErrorCells & cell.Offset(0, -3).value & ", "
End If
Next cell
If Exitflag1 = True And Exitflag2 = True Then
MsgBox "missing information for " & ErrorCells
ElseIf Exitflag1 = True Then
MsgBox "missing lot number for " & ErrorCells
ElseIf Exitflag2 = True Then
MsgBox "missing quantity for " & ErrorCells
Else
With Application.FileDialog(msoFileDialogSaveAs)
.Title = "Save"
.ButtonName = "Save Form"
.Application.DisplayAlerts = False
.InitialFileName = "P:\COMPANY - Production\Production Form Save As Test\" & Range("Save_As!T3").value
If .Show Then
.Execute
End If
End With
End If
End Sub
Private Sub Print_Only2()
ActiveSheet.PrintOut preview:=True
End Sub
Last edited by a moderator: