Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is what I use on one of my sheets. Basically the user double clicks on a cell to bring up a user form; and it highlights the cell yellow when they submit their correction. If they make a mistake then they double-click to remove the highlight. You should be able to just pull out the middle of the code below for what you need.</p> <pre><code>Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Application.EnableEvents = False Dim TargRow As Variant Dim TargCol As Variant TargRow = Target.Row TargCol = Target.Column Header = 8 FirstCol = 0 LastCol = 13 CommentCol = 13 If TargRow &gt; Header And TargCol &gt; FirstCol And TargCol &lt; LastCol Then 'If the cell is clear If Target.Interior.ColorIndex = xlNone Then Cancel = True 'Then change the background to yellow Target.Interior.ColorIndex = 6 Corrections.Show 'Else if the cell background color is already yellow ElseIf Target.Interior.ColorIndex = 6 Then 'Then clear the background Target.Interior.ColorIndex = xlNone End If End If 'This is to prevent the cell from being edited when double-clicked Cancel = True Application.EnableEvents = True End Sub </code></pre> <p>EDITED CODE per comments below:</p> <pre><code>Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'If the target cell is clear If Target.Interior.ColorIndex = xlNone Then 'Then change the background to the specified color Target.Interior.ColorIndex = 4 'But if the target cell is already the specified color ElseIf Target.Interior.ColorIndex = 4 Then 'Then clear the background color Target.Interior.ColorIndex = xlNone End If End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload