Ardus Petus Wrote:
I made a minor correction (Activecell instead of Target) to cope with
errors
that occured when selecting multiple cells with different colors.
HTH
--
AP
'-------
Option Explicit
Private Sub Workbook_SheetSelectionChange( _
ByVal Sh As Object, _
ByVal Target As Excel.Range)
Static OldCell As Range
Static OldFontColor As Long
Static OldBackColor As Long
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = OldBackColor
OldCell.Font.ColorIndex = OldFontColor
End If
Set OldCell = ActiveCell
OldBackColor = ActiveCell.Interior.ColorIndex
OldFontColor = ActiveCell.Font.ColorIndex
Target.Interior.ColorIndex = 6 'Yellow
End Sub
'-------
"Brian Matlack"
a écrit dans le message de
news:Brian.Matlack.26xd7y_1146144602.2854@excelfor um-nospam.com...
Hi!
I got this code off of one of Chip Pearsons sites and it works great
on
a white sheet.
Is there a way to modify it so that:
1. If I have a cell colored Red and I select it and then move on to
another cell the Red cell is now White. I want the cells to revert
back
to whatever their original color was.
2. Can I effect the Font Color as well as the background color and
still have them revert back to the original settings.
<start code
Option Explicit
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Excel.Range)
Static OldCell As Range
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
End If
Target.Interior.ColorIndex = 6 'Yellow
Set OldCell = Target
End Sub
<end code
Thanks for your time and help!
--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile:
http://www.excelforum.com/member.php...fo&userid=3508
View this thread:
http://www.excelforum.com/showthread...hreadid=536781
Thanks Ardus! It works Great!
--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile:
http://www.excelforum.com/member.php...fo&userid=3508
View this thread:
http://www.excelforum.com/showthread...hreadid=536781