Userform: Enable a disabled checkbox by clicking it?

Grummet

Board Regular
Joined
Jun 17, 2014
Messages
80
Hi all,

Situation: A checkbox on a userform is set to .Value = True and .Enabled = False.

My Question: Is there a way to click the disabled checkbox and have it set itself back to .Enabled = True and also changing the Value back to False?

I do not want to re-enable it through clicking another button/checkbox on the form. I know it's silly, but the main reason I want the checkbox disabled in the first place is for the way it looks.

Thanks!

Grummet
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
No, if Enabled = False, you cannot click on it.
 
Upvote 0
Since the mouse click is actually handled by the Userform in that case, you could use something like this:

Code:
Private Sub UserForm_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    With Me.CheckBox1
        If .Enabled = False Then
        If X > .Left And X < .Left + .Width Then
            If Y > .Top And Y < .Top + .Height Then
                .Enabled = True
                .Value = False
            End If
        End If
        End If
    End With
End Sub
 
Upvote 0
Since the mouse click is actually handled by the Userform in that case, you could use something like this:

Code:
Private Sub UserForm_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    With Me.CheckBox1
        If .Enabled = False Then
        If X > .Left And X < .Left + .Width Then
            If Y > .Top And Y < .Top + .Height Then
                .Enabled = True
                .Value = False
            End If
        End If
        End If
    End With
End Sub

Rory, this is excellent! It works flawlessly. I did not know about the MouseUp action, this is good to know for the future :).

Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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