Excel Prevent Save if Checkboxes values are false in excel workbook


AEM

Joined
Sep 13, 2012
Messages
1
Reaction score
0
Hi,

I need a little help to prevent save and show a message if two checkbox values are both false in a workbook.

Currently, I am getting the error below referencing this line in the macro:

CheckBox1.Value = False And CheckBox2.Value = False Then

run-time error '424':
Object required

Any Help is appreciated.

Thanks,
AEM

Here is a sample of the code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If CheckBox1.Value = False And CheckBox2.Value = False Then
Cancel = True
MsgBox "You must check one of the boxes"
End If
End Sub
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top