Question on a Checkbox

menor59

Well-known Member
Joined
Oct 3, 2008
Messages
574
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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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]
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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