VBA msgBox does not appear when ran

hajiali

Well-known Member
Joined
Sep 8, 2018
Messages
624
Office Version
  1. 2016
Platform
  1. Windows
Hello excel experts need help with the below code.
There is way more to the beginning of the code let me know if it is required to help. but for some reason the "Ans = MsgBox("DID YOUR BID PRINT?", vbYesNo)" never appears when the code is ran not sure what I'm doing wrong
any help is greatly appreciated.

Thanks

VBA Code:
  Next
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
    Ans = MsgBox("DID YOUR BID PRINT?", vbYesNo)
    If Ans = vbNo Then
    Exit Sub
    Else
    End If
End With
    Sheets("Form").Visible = xlVeryHidden
    Sheets("Bid").Range("A3:A503,U3:U503,S1").ClearContents
    Sheets("Bid").Select
    ActiveSheet.Protect Password:="password", AllowFiltering:=True
ActiveWorkbook.Save
MsgBox "YOUR BID HAS BEEN SUBMITTED AND PRINTED. PLEASE SIGN PRINTED COPY AND DROP IN THE BID BOX", vbExclamation
Unload Me
Sheets("Bid").Range("S1").Select
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Did the worksheet get printed?
Anyway I'd suggest to show the whole code, I am interested in understanding which event it's linked to.

Bye
 
Upvote 0
it does print and it skips over the Msgbox and proceeds with the rest of the code after End with somehow it never appears

VBA Code:
Private Sub CommandButton1_Click()
Dim Ans As Integer
Dim EmpID$, dDate$, Pin$, Rg As Range, I&, x&
EmpID = TextBox1.Value
Pin = TextBox3.Value
If TextBox1.Value = "" Or TextBox2.Value = "" Or TextBox3.Value = "" Then
   MsgBox "PLEASE FILL IN ALL FIELDS TO PRINT AND SUBMIT BID ... ", vbExclamation: Exit Sub
End If

If Not IsNumeric(EmpID) Then MsgBox "INVALID EMPLOYEE NUMBER ENTER NUMBER WITHOUT THE E", vbExclamation: Exit Sub

With Sheets("BID RESULTS")
   For I = 1 To 2
      dDate = IIf(I = 1, TextBox1.Value, TextBox2.Value)
      If Len(dDate) > 0 Then
         Set Rg = .Columns(1).Find(EmpID, LookAt:=xlWhole)
         If Rg Is Nothing Then
            MsgBox "EMPLOYEE NUMBER DOES NOT EXIST PLEASE TRY AGAIN", vbExclamation:
            TextBox1.Value = ""
            TextBox1.SetFocus
            Exit Sub
         Else
         Set Rg = .Columns(1).Find(EmpID, LookAt:=xlWhole)
    Set Rg = .Cells(Rg.Row, "KW")
If Pin <> Rg Then
        MsgBox "INCORRECT PIN PLEASE TRY AGAIN OR RESET PIN", vbExclamation
        TextBox3.Value = ""
        TextBox3.SetFocus
        Exit Sub
        Else
            Set Rg = IIf(I = 1, ThisWorkbook.Sheets("Bid Data").Cells(2, "E").Resize(1500), ThisWorkbook.Sheets("BID DATA").Range("F" & ThisWorkbook.Sheets("BID DATA").Range("F" & Rows.Count).End(xlUp).Row + 1).Resize(, 1500))
            If InStr(dDate, ".") Then
               For x = 0 To UBound(Split(dDate, "."))
               Next
               For x = 0 To UBound(Split(dDate, "."))
                  Rg.Find("", After:=Rg.Cells(Rg.Count)) = Split(dDate, ".")(x)
               Next
            Else
               Rg.Find("", After:=Rg.Cells(Rg.Count)) = dDate
            End If
         End If
         End If
    ActiveSheet.Unprotect Password:="BNA262"
      Set Rg = IIf(I = 1, ThisWorkbook.Sheets("BID").Cells(1, "S").Resize(1500), ThisWorkbook.Sheets("BID").Cells(3, "U").Resize(1500))
            If InStr(dDate, ".") Then
               For x = 0 To UBound(Split(dDate, "."))
               Next
               For x = 0 To UBound(Split(dDate, "."))
                  Rg.Find("", After:=Rg.Cells(Rg.Count)) = Split(dDate, ".")(x)
               Next
            Else
               Rg.Find("", After:=Rg.Cells(Rg.Count)) = dDate
            End If
            End If
    Sheets("Form").Visible = True
    Sheets("FORM").Select
   Next
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
    Ans = MsgBox("DID YOUR BID PRINT?", vbYesNo)
    If Ans = vbNo Then
    Exit Sub
    Else
    End If
End With
    Sheets("Form").Visible = xlVeryHidden
    Sheets("Bid").Range("A3:A503,U3:U503,S1").ClearContents
    Sheets("Bid").Select
    ActiveSheet.Protect Password:="Password", AllowFiltering:=True
ActiveWorkbook.Save
MsgBox "YOUR BID HAS BEEN SUBMITTED AND PRINTED. PLEASE SIGN PRINTED COPY AND DROP IN THE BID BOX", vbExclamation
Unload Me
Sheets("Bid").Range("S1").Select
End Sub
 
Upvote 0
Never mind I was modify this code which is similar to another code i have and was running the other macro
 
Upvote 0
Glad to know you fixed it by yourself, it was going to be (for me) a little bit complex without a sample worksheet
Bye
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top