Clicked Checkbox Is Not Shown

  • Hi there,
    I would appreciate some assistance to the following problem. The below code populates 10 checkboxes on the form. Clicking on one of them must show up the name of a clicked checkbox however this doesn't happen.
    Is there anything wrong with the code?
    Assistance would be greatly appreciated.


    Class Module

    Public WithEvents myCheckBox As MSForms.CheckBox
    Private Sub myCheckBox_Click()
        MsgBox myCheckBox.Caption
    End Sub
  • I can't explain it but the issue seems to be creating the user form on the fly. If you create a userform and then add your code to the initialize event it will work. There might be a workaround for your scenario but you'll have to wait for someone more knowledgeable than me.

  • Try this, note that you need both Subs and the Function, your Class Module code is fine as it is.

    This will create a User Form named UserForm1 which will replace any existing UserForm with that name.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Thank you , Guys, "new userform's Initialize event" was as well the solution!

    I've created a new form:

    Private Sub UserForm_Initialize()
    End Sub

    Where the event of the old form "Test" changed from Initialize to "Activate", this did the job.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!