Question on a Checkbox

menor59

Active Member
Joined
Oct 3, 2008
Messages
495
Heres My Code

Code:
Sub CheckBox1_Click()
Call UnProtectAll
If Me.CheckBox1.Value = False Then
Range("H2").Interior.Color = 5296274 'green
    Me.Tab.Color = 5296274
Range(ActiveCell.Address).Name = "StartCell"
Clear_DataQuote
Else
Range("H2").Interior.Color = 255 'red
    Me.Tab.Color = 255
Range(ActiveCell.Address).Name = "StartCell"
Clear_DataQuote
End If
Call ProtectAll
End Sub

This is in the code for each worksheet.

What id like to do is if its Checked add a - before the Sheetname in question, and if its unchecked remove the - from the sheetname, keeping the name intact . Basically add a - before the name and remove the - after the name.
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,377
Code:
[color=darkblue]Sub[/color] CheckBox1_Click()
    [color=darkblue]Call[/color] UnProtectAll
    [color=darkblue]If[/color] Me.CheckBox1.Value = [color=darkblue]False[/color] [color=darkblue]Then[/color]
        Range("H2").Interior.Color = 5296274    [color=green]'green[/color]
        Me.Tab.Color = 5296274
        [color=darkblue]If[/color] Left(Me.Name, 1) = "-" [color=darkblue]Then[/color] Me.Name = Mid(Me.Name, 2)
    [color=darkblue]Else[/color]
        Range("H2").Interior.Color = 255    [color=green]'red[/color]
        Me.Tab.Color = 255
        Me.Name = "-" & Me.Name
    [color=darkblue]End[/color] [color=darkblue]If[/color]
    Clear_DataQuote
    ActiveCell.Name = "StartCell"
    [color=darkblue]Call[/color] ProtectAll
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 

Watch MrExcel Video

Forum statistics

Threads
1,122,370
Messages
5,595,774
Members
414,018
Latest member
quang118

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
Top