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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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,215,430
Messages
6,124,846
Members
449,194
Latest member
HellScout

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