vendredi 23 octobre 2020

VBA Checkbox: Remove mark when information is missing

In the file I'm working on, I have set a checkbox that needs to be ticked to confirm that your boss has read the report. If information is missing, you will get a warning message telling you to fill all the data. Now I noticed that if you tick the checkbox after filling the whole template and then you delete some information, the ckeckmark does not disappear. Is there a way to make the checkmark go away if you delete some data afterwards, followed by a message to fill the whole info again and also tick the checkbox again?

This is the code I'm using:

Private Sub CheckBox1_Click()

Dim c As Range

For Each c In

ActiveSheet.Range(("D12:E20,C22:E22,D26:D27,F26,D30:D33,D35:D36,E31,D39,D40:E42,D45:D46,D49,D52,D53:F58,D61,C64:F65,C67:F67,D68,C71:F72,C74:F74,D75,C78:F79,C81:F81,D85"))

If c = "" Then

MsgBox "Please fill-out the missing cells!"

Cancel = True

If CheckBox1.Value = True Then CheckBox1.Value = False

Exit For

End If

Next

End Sub

Thank you!




Aucun commentaire:

Enregistrer un commentaire