title: How to apply vba code which highlights active selected cell to all active sheets?
body: <p>I am currently trying to apply this code below to active sheets by converting it to macro. However I am having trouble with for each function. </p>
  
  <p>This is the original code. </p>
  
  <pre><code>Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
      'Update 20140318
      Static xRow
      Static xColumn
      If xColumn &lt;&gt; "" Then
          With Columns(xColumn).Interior
              .ColorIndex = xlNone
          End With
          With Rows(xRow).Interior
              .ColorIndex = xlNone
          End With
      End If
      pRow = Selection.Row
      pColumn = Selection.Column
      xRow = pRow
      xColumn = pColumn
      With Columns(pColumn).Interior
          .ColorIndex = 22
          .Pattern = xlSolid
      End With
      With Rows(pRow).Interior
          .ColorIndex = 6
          .Pattern = xlSolid
      End With
  End Sub
  </code></pre>
  
  <p>My unsuccessful attempt to convert : </p>
  
  <pre><code>Sub Highlighter()
  '
  ' Highlighter Macro
  '
  ' Keyboard Shortcut: Ctrl+Shift+H
  '
  Dim xSheet As Worksheet
  
  For Each xSheet In This.Workbook.Worksheets
      xSheet.Select
      Static xRow
      Static xColumn
  
      If xColumn &lt;&gt; "" Then
          With Columns(xColumn).Interior
              .ColorIndex = xlNone
          End With
          With Rows(xRow).Interior
              .ColorIndex = xlNone
          End With
      End If
      pRow = Selection.Row
      pColumn = Selection.Column
      xRow = pRow
      xColumn = pColumn
      With Columns(pColumn).Interior
          .ColorIndex = 22
          .Pattern = xlSolid
      End With
      With Rows(pRow).Interior
          .ColorIndex = 6
          .Pattern = xlSolid
  
  
  
  Next xSheet
  
  End Sub
  </code></pre>
  
  <p>Please help! Thanks! </p>
  
  <p>Third attempt >>  It is working but how to do Selection Change within workbook to apply to all sheets? </p>
  
  <pre><code>Sub Highlighter()
  '
  ' Highlighter Macro
  '
  ' Keyboard Shortcut: Ctrl+Shift+H
  '
  
  
  Dim xSheet As Worksheet
  
  For Each xSheet In ActiveWorkbook.Worksheets
  
  
  xSheet.Select
  Static xRow
  Static xColumn
  
  If xColumn &lt;&gt; "" Then
      With xSheet.Columns(xColumn).Interior
          .ColorIndex = xlNone
      End With
      With xSheet.Rows(xRow).Interior
          .ColorIndex = xlNone
      End With
  End If
  pRow = Selection.Row
  pColumn = Selection.Column
  xRow = pRow
  xColumn = pColumn
  With xSheet.Columns(pColumn).Interior
      .ColorIndex = 22
      .Pattern = xlSolid
  End With
  With xSheet.Rows(pRow).Interior
      .ColorIndex = 6
      .Pattern = xlSolid
  
  End With
  </code></pre>