XL2K - Conditional Formatting relative to cell selection

L

Lezh

Is there a way I can change the colour of an array of cells depending on
whether a different specified cell in the worksheet has been selected?

For example, the conditional formula in each cell in the range X1:Z3
would effectively be: 'if A1 is the currently selected cell, turn me
green'. :)

Thanks - Lez
 
G

Gary''s Student

Enter this macro:

Sub Macro1()
Dim r As Range
Set r = Range("A1")
If Not Intersect(r, Selection) Is Nothing Then
Range("X1:Z3").Select
With Selection.Interior
.ColorIndex = 4
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
End Sub


If you select A1 and then run the macro, the other cells will be colored.
 
S

Stefi

Create this UDF:
Public Function AktCell() As String
Application.Volatile
AktCell = ActiveCell.Address(False, False)
End Function

Create this event procedure:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Calculate
End Sub

Apply Conditional formatting in the range X1:Z3
formula: =AktCell()="A1"
and choose green background!

Regards,
Stefi



„Lezh†ezt írta:
 
L

Lezh

Thanks GS and Stefi for your input. Although my xl experience has bee
limited to the commoner formulas up till now (though I recorded a macr
once and it worked!) I'll try your solutions as a cure for the new yea
hangover at the weekend - but I think I might just have to read up
bit on how to enter this stuff! :confused: :(

Much appreciate your help. Thanks again. :
 
Top