Checkbox to change it's own label?

tigger6333

New Member
Joined
Sep 6, 2009
Messages
43
Greetings wise ones

I would love to have a checkbox which, when ticked, changes it's text label to the date.
eg [] Checkbox1 would become [√] 27-4-14

My macro skills are less than basic so I am requesting assistance.

Does anyone know if this can be done and, if so, how?

Thanks
Keith
 

phantom1975

MrExcel MVP
Joined
Jun 3, 2002
Messages
3,962
Are you referring to a checkbox on a Userform or a checkbox embedded on a worksheet?
 

xrichardx

Board Regular
Joined
Apr 24, 2013
Messages
67
@tigger

Just in case you are reffering to a userform. The below code could help.

Code:
 If (Me.CheckBox1.Value = True) Then
    Me.CheckBox1.Caption = Date
 Else
    Me.CheckBox1.Caption = "CheckBox"
 End If
Cheers
Chard
 

phantom1975

MrExcel MVP
Joined
Jun 3, 2002
Messages
3,962
@tigger

Just in case you are reffering to a userform. The below code could help.

Code:
 If (Me.CheckBox1.Value = True) Then
    Me.CheckBox1.Caption = Date
 Else
    Me.CheckBox1.Caption = "CheckBox"
 End If
Cheers
Chard

Keep in mind that the code will need to be entered into the appropriate Checkbox event. You will also want to consider how you want the date formatted. Me.Checkbox1.Caption = Format(Date,"dd-m-yy")

Oh yeah, if it is a checkbox that is embedded on the worksheet, there are two different checkboxes. One of them is from the Forms toolbox and the other is from...well...some other one. I forgot the toolbox. The two work a little differently.
 

xrichardx

Board Regular
Joined
Apr 24, 2013
Messages
67
@phantom

Thanks, I'll keep that in mind. :)

I was actually assuming that tigerr already knew the basic (oh yeah he mentioned less than basic :) ). Well, just in case, I'll add as well the event and date format.

Code:
Private Sub CheckBox1_Click()

 If (Me.CheckBox1.Value = True) Then
    Me.CheckBox1.Caption = Format(Date,"dd-m-yy")
 Else
    Me.CheckBox1.Caption = "CheckBox"
 End If
 
End Sub
Cheers
Chard
 

tigger6333

New Member
Joined
Sep 6, 2009
Messages
43
Ah, the wisest of the wise have helped.

I appreciate your help and wisdom. I particularly like the Format option too.

Thanks very much.

(bows deeply)
 

Forum statistics

Threads
1,086,241
Messages
5,388,649
Members
402,129
Latest member
saltoftheearth

Some videos you may like

This Week's Hot Topics

Top