I am a self taught newbie in Excel VBA, so my question could be very trivial.

I have a UserForm that, among other things, has a CheckBox in it. Say CB1. I would like CB1 to show its last state, whenever I open the UserForm. If it was TRUE last time, I want it to show the check mark, in full black, when I open the form. How do I do that


Re: Check Boxes

Andy Pope


You need to store the control state just before the userform is unloaded.
The simplest place to store the setting is in a worksheet. This can be hidden if required.

And then when the userform is loaded you read the value back from the worksheet.

Private Sub UserForm_Initialize()

CB1.Value = (Sheet1.Range("A1").Value = True)

End Sub

Private Sub UserForm_Terminate()

Sheet1.Range("A1").Value = CB1.Value

End Sub

Re: Check Boxes


Thanks Andy Pope:

It works!!!