ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   a way to color the CURRENT row or cell when selected (https://www.excelbanter.com/excel-programming/330997-re-way-color-current-row-cell-when-selected.html)

haneira

a way to color the CURRENT row or cell when selected
 

How can deactivate the function Sub Worksheet_SelectionChange?


--
haneira
------------------------------------------------------------------------
haneira's Profile: http://www.excelforum.com/member.php...o&userid=24065
View this thread: http://www.excelforum.com/showthread...hreadid=372145


Nick Hebb

a way to color the CURRENT row or cell when selected
 
If you want the currently selected range/cell to be colored and the
color cleared from the previously selected range or cell, then you will
need to keep track of that last range selected.

Declare a private variable at the module level, and set its range upon
activation. Then when SelectionChange is called, clear the last range,
color the target range and set the last range variable to the current
target, as follows

Private lastRange As Range ' module level declaration

Private Sub Worksheet_Activate()
Set lastRange = ActiveCell
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
lastRange.Interior.ColorIndex = xlColorIndexNone
Target.Interior.Color = RGB(255, 255, 0) ' yellow
Set lastRange = Target
End Sub


Ivan F Moala[_50_]

a way to color the CURRENT row or cell when selected
 

This maybe useful for you ??

http://office.microsoft.com/en-us/as...366231033.aspx

If conditionall formating is a problem ... then here is an
alternative.

http://www.xcelfiles.com/Excel02.html#anchor_67


--
Ivan F Moala


------------------------------------------------------------------------
Ivan F Moala's Profile: http://www.excelforum.com/member.php...fo&userid=1954
View this thread: http://www.excelforum.com/showthread...hreadid=372145



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

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