Identify the Current Cell

  • Thread starter Thread starter Staanley
  • Start date Start date
S

Staanley

I would like to highlight/shade a certain cell in whichever row I am
currently working on. For example, whenever I am anywhere on row 10 I would
like cell A10 to be highlighted or shaded a certain colour, and similarly for
row 11 cell A11 etc. I have been looking for a function like ACTIVEROW or
ACTIVECELL so that I can then use conditional formatting, but can't find
anything.
I am using EXCEL 2007.

Please help. Thanks.
 
How about this? Be aware, it will destroy any other CF you have


'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
With .EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With
End With
With .EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With
End With

.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Bob,
Thanks very much. The problem I have is that the worksheet is quite heavily
formatted and I guess this would destroy that.
I would say I am a fairly competent EXCEL user, but am not an expert, so I
hope I have not misunderstood you.
Cheers,
Ian.
 
It won't destroy formatting, other than any conditional formatting It does
destroy that I am afraid.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Back
Top