Hi,
I am trying to insert the worksheet 'Quality Check Form' into a new workbook and have the code below work. It is bringing the code over with the sheet but the macro is not working. I believe the code needs to be applied to the workbook the sheet is being imported to apposed to just the sheet, which is the case at the moment. Please can somone offer some advise on how to insert this sheet into a new workbook and have the VBA below work? Many thanks, Jourden.
Option Explicit
Public Sub Workbook_BeforeClose(Cancel As Boolean)
With Worksheets("Quality Check Form")
If .Range("I11").Value = "" Or _
.Range("I12").Value = "" Or _
.Range("B52").Value = "" And .Range("I52").Value = "" Then
MsgBox "Quality Check Form Critical Error" & vbNewLine & vbNewLine & _
"Please Enter the Mandatory Fields Highlighted in Yellow.", vbCritical, "Critical Error"
'Cancel = True
End If
End With
End Sub
<!-- END TEMPLATE: bbcode_code -->
I am trying to insert the worksheet 'Quality Check Form' into a new workbook and have the code below work. It is bringing the code over with the sheet but the macro is not working. I believe the code needs to be applied to the workbook the sheet is being imported to apposed to just the sheet, which is the case at the moment. Please can somone offer some advise on how to insert this sheet into a new workbook and have the VBA below work? Many thanks, Jourden.
Option Explicit
Public Sub Workbook_BeforeClose(Cancel As Boolean)
With Worksheets("Quality Check Form")
If .Range("I11").Value = "" Or _
.Range("I12").Value = "" Or _
.Range("B52").Value = "" And .Range("I52").Value = "" Then
MsgBox "Quality Check Form Critical Error" & vbNewLine & vbNewLine & _
"Please Enter the Mandatory Fields Highlighted in Yellow.", vbCritical, "Critical Error"
'Cancel = True
End If
End With
End Sub
<!-- END TEMPLATE: bbcode_code -->