+ Reply to Thread
Results 1 to 3 of 3

Highlight Text In Cell if Checkbox is Un-Checked

Hybrid View

dmartin55 Highlight Text In Cell if... 01-22-2021, 02:41 PM
protonLeah Re: Highlight Text In Cell if... 01-22-2021, 04:03 PM
dmartin55 Re: Highlight Text In Cell if... 01-22-2021, 06:09 PM
  1. #1
    Registered User
    Join Date
    06-22-2020
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2016
    Posts
    14

    Highlight Text In Cell if Checkbox is Un-Checked

    Greetings,

    Currently I have Active X Control Check boxes where if the box is checked, the sheet will be displayed who's name matches the check box's caption. If the box is unchecked, the sheet becomes hidden. I want to add another layer to this where if the box is unchecked, then the linked cell's text will be a light grey (almost to where you can't see the name) to visually indicate (more so) that the sheet isn't being used.

    Attached is a sample workbook that already has the code to hide the sheets when the checkboxes are unchecked.
    The code is located in Sheet6(Checkboxes).

    Existing Code for CheckBox1


    Private Sub CheckBox1_Click()
    
    Dim ws As Worksheet
    Set ws = ActiveSheet
    
    If Sheets(CheckBox1.Caption).Visible = xlHidden Then
        Sheets(CheckBox1.Caption).Visible = -1
    
    Else
        Sheets(CheckBox1.Caption).Visible = xlHidden
    
    End If
    
    
    End Sub
    Attached Files Attached Files
    Last edited by dmartin55; 01-22-2021 at 02:46 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,969

    Re: Highlight Text In Cell if Checkbox is Un-Checked

    One way:

    Private Sub CheckBox1_Click()
        Dim ws As Worksheet
        Set ws = ActiveSheet
        If Sheets(CheckBox1.Caption).Visible = xlHidden Then
            Sheets(CheckBox1.Caption).Visible = -1
             With CheckBox1
                Cells(.TopLeftCell.Row, .TopLeftCell.Column).Font.Color = RGB(178, 178, 178)
            End With
       Else
            Sheets(CheckBox1.Caption).Visible = xlHidden
            With CheckBox1
                Cells(.TopLeftCell.Row, .TopLeftCell.Column).Font.Color = vbBlack
            End With
    
        End If
    End Sub
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    06-22-2020
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2016
    Posts
    14

    Re: Highlight Text In Cell if Checkbox is Un-Checked

    Quote Originally Posted by protonLeah View Post
    One way:

    Private Sub CheckBox1_Click()
        Dim ws As Worksheet
        Set ws = ActiveSheet
        If Sheets(CheckBox1.Caption).Visible = xlHidden Then
            Sheets(CheckBox1.Caption).Visible = -1
             With CheckBox1
                Cells(.TopLeftCell.Row, .TopLeftCell.Column).Font.Color = RGB(178, 178, 178)
            End With
       Else
            Sheets(CheckBox1.Caption).Visible = xlHidden
            With CheckBox1
                Cells(.TopLeftCell.Row, .TopLeftCell.Column).Font.Color = vbBlack
            End With
    
        End If
    End Sub
    Switched with statements. When box is unchecked, the text is grey and the sheet is hidden. Thanks!! Now to update 40 checkboxes...

    Private Sub CheckBox1_Click()
        Dim ws As Worksheet
        Set ws = ActiveSheet
        If Sheets(CheckBox1.Caption).Visible = xlHidden Then
            Sheets(CheckBox1.Caption).Visible = -1
            With CheckBox1
                Cells(.TopLeftCell.Row, .TopLeftCell.Column).Font.Color = vbBlack
            End With
       Else
            Sheets(CheckBox1.Caption).Visible = xlHidden
             With CheckBox1
                Cells(.TopLeftCell.Row, .TopLeftCell.Column).Font.Color = RGB(178, 178, 178)
            End With
        End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do I generate text for rows whos checkbox is not checked?
    By Wiigit in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-26-2018, 12:56 PM
  2. Checkbox to date stamp cell when checked
    By jsherwood in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-22-2018, 11:43 AM
  3. [SOLVED] Checkbox Copy and Paste info only when checked to another cell
    By MonTheEck in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-22-2018, 06:23 AM
  4. [SOLVED] Want to shade cell when checkbox is checked
    By oneuglydude in forum Excel General
    Replies: 2
    Last Post: 01-02-2015, 08:13 AM
  5. [SOLVED] When checkbox is checked it does not copy to new sheet. Only if not checked using false
    By thelisa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2013, 07:59 AM
  6. Replies: 4
    Last Post: 02-04-2011, 06:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1