Forum Discussion

Anthony Smith's avatar
Anthony Smith
Brass Contributor
Jul 12, 2018
Solved

How to highlight a cell and display a message when a checkbox is checked?

Hello,

 

I am looking for a solution on how to highlight a specific cell when a checkbox (form) is checked. The range is A1:S104. I wish to highlight cell G66 when checkbox13 is selected. I would also like to display a simple message box. 

 

Any help is appreciated!

 

Thanks!

  • Hi Anthony,

     

    This is can be done as below screenshot.

     

     

    The Check Box 1 is powered by this macro:

    Sub CheckBox1_Click()

        If ActiveSheet.Shapes("Check Box 1").ControlFormat.Value = 1 Then
            Range("G66").Interior.Color = vbYellow
            MsgBox ("The cell G66 in now highlighted!")
        Else
            Range("G66").ClearFormats
        End If

    End Sub

     

    Please see the attached file.

    Regards

2 Replies

  • Haytham Amairah's avatar
    Haytham Amairah
    Silver Contributor

    Hi Anthony,

     

    This is can be done as below screenshot.

     

     

    The Check Box 1 is powered by this macro:

    Sub CheckBox1_Click()

        If ActiveSheet.Shapes("Check Box 1").ControlFormat.Value = 1 Then
            Range("G66").Interior.Color = vbYellow
            MsgBox ("The cell G66 in now highlighted!")
        Else
            Range("G66").ClearFormats
        End If

    End Sub

     

    Please see the attached file.

    Regards

    • Anthony Smith's avatar
      Anthony Smith
      Brass Contributor
      Thank you so much. I just adjusted the code a bit to clear just the highlighting instead of all the formats.

Resources