View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bill Oertell[_2_] Bill Oertell[_2_] is offline
external usenet poster
 
Posts: 18
Default Worksheet_SelectionChange

Found this bit of code on a website. Can't remember where, but I can find out
if anyone's interested. The initial row does not remain highlighted. Works
rather nicely. And it has the advantage of not highlighting the row if it's
empty.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim strRow As String
Cells.FormatConditions.Delete

With Target.EntireRow
strRow = .Address
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=COUNTA(" & strRow &
")0"
.FormatConditions(1).Interior.ColorIndex = 6
End With
End Sub

But I do have one question. How does the the line of code:
..FormatConditions.Add Type:=xlExpression, Formula1:="=COUNTA(" & strRow & ")0"
prevent the sub from highlighting an empty row. I understand the COUNTA
function, but I don't understand how that line prevents the following line from
executing.

Thanks.