Highlight Active Cell Depends on custom Ribbon CheckBOX

  • I have my own ribbon, wherein there is one check box. If the checkbox is checked, highlight active row and active column, wherever I move to any cell in any worksheet. It is not working. Help me.

  • Possibly...

    If I've been helpful, let me know. If I haven't, let me know that too. 

  • Possibly...

    Sir, problem could not be resolved. The matter is I have a checkbox in my custom iribbon. When I check this checkbox, wherever I click on any cells on any worksheet, the relative row and relative column should be highlighted. VB Code replied by you and Code mentioned in the Public Function Function_Action do the same work, but only one time. I want the highlighting on every click till the Checkbox is unchecked. Can it be possible to call Public Function Worksheet_SelectionChange(ByVal Target As Range) when pressed is true.

    ' I need to call Call Worksheet_SelectionChange(ByVal Target As Range) when pressed is true

    Code
    Public Function Worksheet_SelectionChange(ByVal Target As Range)
    Cells.Interior.ColorIndex = xlColorIndexNone
    Target.EntireColumn.Interior.ColorIndex = 28
    Target.EntireRow.Interior.ColorIndex = 28
    Target.Interior.ColorIndex = xlColorIndexNone
    End Function
  • Welcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags

    Note: no apostrophe in the tags, just used for demonstration here.

    ['code]


    your code goes between these tags


    ['/code]


    Or, just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Thanks.

  • Please let me know when you have read the Forum Rules. If I don't hear back soon then I will close this question. You have 24 posts so should be familiar with the rules by now.

  • Sorry for breach of rules of forum.


    Sir, problem could not be resolved. The matter is I have a checkbox in my custom iribbon. When I check this checkbox, wherever I click on any cells on any worksheet, the relative row and relative column should be highlighted. VB Code replied by you and Code mentioned in the Public Function Function_Action do the same work, but only one time. I want the highlighting on every click till the Checkbox is unchecked. Can it be possible to call Public Function Worksheet_SelectionChange(ByVal Target As Range) when pressed is true.

    iRIBBON as follows:

    Code
    <checkBox id="cbHighlight" 
    label="Highlight" 
    supertip="This will highlight active Row and Column, wherever you click on the cell." 
    onAction="Function_Action" />

    Module Code:

    Code
    Public Function Function_Action(control As IRibbonControl, pressed As Boolean)
    If pressed Then
    ActiveCell.EntireRow.Interior.ColorIndex = 20
    ActiveCell.EntireColumn.Interior.ColorIndex = 20
    Else
    Cells.Interior.ColorIndex = xlColorIndexNone
    End If
    End Function
    Code
    Public Function Worksheet_SelectionChange(ByVal Target As Range)
    Cells.Interior.ColorIndex = xlColorIndexNone
    Target.EntireColumn.Interior.ColorIndex = 20
    Target.EntireRow.Interior.ColorIndex = 20
    Target.Interior.ColorIndex = xlColorIndexNone
    End Function
  • Try...

    If I've been helpful, let me know. If I haven't, let me know that too. 

  • royUK, I did a search for VBA code to highlight just the active cell and came across this thread. Is there a simplified code just for the active cell, or should I submit as a seperate thread?


    Dandelor, this is interesting about having a checkbox in a my custom ribbon, can you tell me how to add a checkbox to the ribbon?

  • The Forum Rules ask you not to post questions in another person's Thread.


    Please start your own post. By all means add a link to a Thread that may be related to your question.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!