Trying to Prevent Printing With Form Control Checkboxes

Evan1

New Member
Joined
Jun 1, 2018
Messages
8
Hello,

I have an excel sheet that has multiple line items that a user needs to check a "Required" checkbox or a "N/A" checkbox. If the "Required" checkbox is selected, then the user either needs to select a "Completed" checkbox OR fill in a comment in a cell to explain why it is not yet completed. All of the checkboxes are Form Control checkboxes and not ActiveX Control checkboxes.

I would like to prevent the user from being able to print the form unless it is filled out correctly. Basically, if the "Required" checkbox ("Check Box 161") is selected AND the "Completed" checkbox ("Check Box 4") is deselected AND there is no comment in cell J9, then cancel printing. So far, the code I have under the ThisWorkbook section is...

Code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)

If Sheets("Sheet1").CheckBoxes("Check Box 161").Value = 1 And Sheets("Sheet1").CheckBoxes("Check Box 4").Value = 0 And Sheets("Sheet1").Range("J9").Value = "" Then
Cancel = True
MsgBox ("Please Insert Comment on Line 9")
End If

End Sub

I have changed the name of the sheet to sheet1 for this example, but I have the real sheet name in my code. I can get this code to work with just the J9 value section, but it won't work with form control checkbox codes. I can get it to work if I were to insert in a new ActiveX control checkboxes and use those proper names, but I would prefer not to change all of my boxes to ActiveX boxes because that will be quite a bit of code for me to change.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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