Question on a Checkbox

menor59

Well-known Member
Joined
Oct 3, 2008
Messages
570
Office Version
  1. 2021
Platform
  1. Windows
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.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,450
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]
 

menor59

Well-known Member
Joined
Oct 3, 2008
Messages
570
Office Version
  1. 2021
Platform
  1. Windows
You Are the Man!!!!
 
Last edited:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,142
Messages
5,835,646
Members
430,373
Latest member
swartzfeger

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