View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Geoff Geoff is offline
external usenet poster
 
Posts: 371
Default Activate data according to the value key in in other cell.

You may also want to consider:

hth

Geoff

Sub HighLightCells()

Dim tbl As Range, tbl2 As Range, rng As Range, rng2 As Range
Dim found As Range, found2 As Range

'''set search range in col A
Set tbl = Range("A1:A" & Range("A65536").End(xlUp).Row)

For Each rng In tbl
'''find row in col A
Set found = tbl.Find(rng.Value, , xlValues, xlWhole, xlNext, xlByRows)
If Not found Is Nothing Then
Set tbl2 = Range(Cells(found.Row, 2), Cells(found.Row, 4))
For Each rng2 In tbl2
If Not IsEmpty(rng2) And rng2.Value 0 Then
Select Case rng.Value
Case "A"
'''rng2.Font.Color = vbRed '''*****use this
rng2.Interior.Color = vbRed '''*****or this
Case "B"
'''rng2.Font.Color = vbBlue
rng2.Interior.Color = vbCyan
Case "C"
'''rng2.Font.Color = vbGreen
rng2.Interior.Color = vbGreen
Case "D"
'''rng2.Font.Color = vbMagenta
rng2.Interior.Color = vbMagenta
Case Else
End Select
End If
Next
End If
Next

End Sub

" wrote:

Hi

I need to activate data according to the value key in in other cell.
eg:

If Then
A 1 2
B 1 3
C 2 3
D 1 2 3

if the value is A then 1 and 2 should be highlighted
and if B then 1 and 3,
if C then 2 and 3
and if D then 1,2 and 3 should be highlighted or viewed