Checkbox change event help

Niss1

New Member
Joined
Jul 8, 2011
Messages
20
I am doing some changes to an old excel sheet and i have a Label i wish to change to a checkbox(form control) (if possible)


This is the old code for the label:
Code:
Private Sub Label1_Click()
If Label1.Caption = Chr(252) Then
 Label1.Caption = ""
 rows("29:49").Hidden = True

 Else
 Label1.Caption = Chr(252)
 rows("29:49").Hidden = False

 End If
End Sub


I have tried to do this, but it doesnt work. Hopefully someone can give me some feedback on this.
Code:
Private Sub CheckBox1_Change()
If CheckBox1.Value = True Then
 rows("29:49").Hidden = False
 Else
 CheckBox1.Value = False
 rows("29:49").Hidden = True

 End If
End Sub

I have chosen a checkbox of the form control type.


Thanks in advance!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
You need ActiveX checkbox. Form's control can only be assigned to macro, or OnAction property can trigger some Sub.
 
Upvote 0
That worked perfectly fine of course

although i was hoping to use the normal checkboxes as they are visually much nicer than the activex ones.
 
Upvote 0
You can create one Sub and assign it to numerous Forms checkboxes.
Here's example.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,331
Members
452,907
Latest member
Roland Deschain

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