Dim
row1
As
Long
, rown
As
Long
Private
Sub
worksheet_SelectionChange(
ByVal
Target
As
Range)
If
row1 = 0
Then
row1 = 1
rown = 1
End
If
For
i = row1
To
rown
Rows(i).Interior.Pattern = xlPatternSolid
If
Rows(i).Interior.ColorIndex = xlPatternAutomatic
Then
Rows(i).Interior.Pattern = xlNone
Else
rown = i
End
If
Next
i
For
Each
c
In
Rows(row1 &
":"
& rown).Columns
If
c.Interior.ColorIndex = xlPatternAutomatic
Then
c.Interior.ColorIndex = xlNone
ElseIf
IsNull(c.Interior.ColorIndex)
Then
c.Interior.Pattern = xlPatternSolid
For
Each
cl
In
c.Cells
If
cl.Interior.ColorIndex = xlPatternAutomatic
Then
cl.Interior.Pattern = xlNone
Next
cl
Else
c.Interior.Pattern = xlPatternSolid
End
If
Next
c
row1 = Target.Row: rown = Target.Row + Target.Rows.Count - 1
For
Each
r
In
Target.Rows
Rows(r.Row).Interior.Pattern = xlGray50
Rows(r.Row).Interior.PatternColor = 12632256
Next
r
End
Sub