Guest User

Untitled

a guest
Jul 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Sub HighLightCells()
  2. ActiveSheet.UsedRange.Cells.FormatConditions.Delete
  3. ActiveSheet.UsedRange.Cells.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
  4. Formula1:=ActiveCell
  5. ActiveSheet.UsedRange.Cells.FormatConditions(1).Interior.ColorIndex = 4
  6. End Sub
  7.  
  8. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  9. call HighLightCells
  10. End Sub
  11.  
  12. Sub HighlightCells()
  13. Dim rCell As Range
  14.  
  15. If ActiveCell.Value = vbNullString Then Exit Sub
  16.  
  17. Set rCell = ActiveCell
  18.  
  19. Do
  20. Set rCell = ActiveSheet.UsedRange.Cells.Find(ActiveCell.Value, rCell)
  21.  
  22. If rCell.Address <> ActiveCell.Address Then
  23. rCell.Interior.Color = 65535
  24. Else
  25. Exit Do
  26. End If
  27. Loop
  28.  
  29. End Sub
Add Comment
Please, Sign In to add comment