ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do I shade cells during selection? (https://www.excelbanter.com/excel-worksheet-functions/29169-how-do-i-shade-cells-during-selection.html)

MysterTLC

How do I shade cells during selection?
 
I am trying to shade cells only when they are selected unless I specify them
to be shaded all the time. Is this possible?
I am using Excel 2003

Don Guillett

try this. Right click sheet tabview codeinsert thisSAVE workbook

'McCurdy.Here is something inspired by Don Guillett.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MyRng As Range
Set MyRng = Target.EntireRow
Application.EnableEvents = False
On Error GoTo end1
Application.Cells.FormatConditions.Delete
With MyRng
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ROW()=ROW(INDIRECT(CELL(""address"")))"
With .FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 1
End With
.FormatConditions(1).Interior.ColorIndex = 36
End With
end1:
Application.EnableEvents = True
End Sub

--
Don Guillett
SalesAid Software

"MysterTLC" wrote in message
...
I am trying to shade cells only when they are selected unless I specify

them
to be shaded all the time. Is this possible?
I am using Excel 2003





All times are GMT +1. The time now is 01:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com