Insert VBA Code into New Workbook module from Sheet

Jourden

New Member
Joined
Apr 3, 2013
Messages
3
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 -->​
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,215,561
Messages
6,125,542
Members
449,236
Latest member
Afua

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