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.

  • GIRISHBISHT

    Changed the title of the thread from “Highlight Active Cell Depends on custom Ribbon Check” to “Highlight Active Cell Depends on custom Ribbon CheckBOX”.
  • 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
    1. Public Function Worksheet_SelectionChange(ByVal Target As Range)
    2. Cells.Interior.ColorIndex = xlColorIndexNone
    3. Target.EntireColumn.Interior.ColorIndex = 28
    4. Target.EntireRow.Interior.ColorIndex = 28
    5. Target.Interior.ColorIndex = xlColorIndexNone
    6. 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
    1. <checkBox id="cbHighlight"
    2. label="Highlight"
    3. supertip="This will highlight active Row and Column, wherever you click on the cell."
    4. onAction="Function_Action" />

    Module Code:

    Code
    1. Public Function Function_Action(control As IRibbonControl, pressed As Boolean)
    2. If pressed Then
    3. ActiveCell.EntireRow.Interior.ColorIndex = 20
    4. ActiveCell.EntireColumn.Interior.ColorIndex = 20
    5. Else
    6. Cells.Interior.ColorIndex = xlColorIndexNone
    7. End If
    8. End Function
    Code
    1. Public Function Worksheet_SelectionChange(ByVal Target As Range)
    2. Cells.Interior.ColorIndex = xlColorIndexNone
    3. Target.EntireColumn.Interior.ColorIndex = 20
    4. Target.EntireRow.Interior.ColorIndex = 20
    5. Target.Interior.ColorIndex = xlColorIndexNone
    6. 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.