ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Highlighting a cell (https://www.excelbanter.com/excel-programming/299532-highlighting-cell.html)

Vlad[_7_]

Highlighting a cell
 
Is there a way to highlight a cell (different color) when it's selected.
For example, cell A1 becomes yellow when selected? However, once I select a
different cell the new cell become yellow and A1 goes back to white.
Thanks.



Frank Kabel

Highlighting a cell
 
Hi
see: http://www.cpearson.com/excel/RowLiner.htm

--
Regards
Frank Kabel
Frankfurt, Germany

"Vlad" schrieb im Newsbeitrag
om...
Is there a way to highlight a cell (different color) when it's

selected.
For example, cell A1 becomes yellow when selected? However, once I

select a
different cell the new cell become yellow and A1 goes back to white.
Thanks.




Bob Phillips[_6_]

Highlighting a cell
 
Vlad,

Here is one way that highlights the row and column of the activecell. Not in
your colours but you can adapt to suit

Private Sub WorkSheet_SelectionChange(ByVal Target As Range)

Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
With Target.EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
With Target
.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 Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Vlad" wrote in message
om...
Is there a way to highlight a cell (different color) when it's selected.
For example, cell A1 becomes yellow when selected? However, once I select

a
different cell the new cell become yellow and A1 goes back to white.
Thanks.





Vlad[_7_]

Highlighting a cell
 
Bob and Frank,
Thanks a lot. This is exactly what I was looking for.

"Bob Phillips" wrote in message
...
Vlad,

Here is one way that highlights the row and column of the activecell. Not

in
your colours but you can adapt to suit

Private Sub WorkSheet_SelectionChange(ByVal Target As Range)

Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
With Target.EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
With Target
.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 Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Vlad" wrote in message
om...
Is there a way to highlight a cell (different color) when it's selected.
For example, cell A1 becomes yellow when selected? However, once I

select
a
different cell the new cell become yellow and A1 goes back to white.
Thanks.








All times are GMT +1. The time now is 09:41 AM.

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