View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Click a cell and all related cells are colour highlighted

Dear

If you are new to VBA set the Security level to low/medium in
(Tools|Macro|Security). Right click on the sheet tab on which you would like
to have this highligtion and click on 'View Code'. Paste the below code.

I have defined the applicable range as B1:J10 and the range in Col A as
A1:A10. You can change this as per your requirement..I hope you understand
the code which is rather simple. Setting the color to xlNone. With a loop it
checks whether any of the cells contain a value same as that of target. If
found color the interior. If you want to highlight blanks uncomment the two
marked lines (which appears in green within VBE).

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rngTemp As Range
Set rngTemp = Range("B1:J10")
rngTemp.Interior.ColorIndex = xlNone
If Not Application.Intersect(Target, Range("A1:A10")) Is Nothing Then
'If Target.Value < "" Then
For Each cell In rngTemp
If Target.Value = cell.Value Then
cell.Interior.Color = vbYellow
End If
Next
'End If
End If
End Sub

Try and feedback. Wish you all good luck..

If this post helps click Yes
---------------
Jacob Skaria


"Cat Woman" wrote:

In a table I would like to click on a text item in first column and all text
cells that are related to this item would appear highligted in, say, yellow.
Procedure able to be repeated for any item in first column.

I am Excel beginner so if anyone knows how to do this, step by step
instructions would be great. Thank you.