How to change row color when select a cell in this row?

How to change row color when select a cell in this row?

Post by Amoli » Fri, 16 Apr 2004 14:07:15


How to change row color when select a cell in this row?

Thank you
 
 
 

How to change row color when select a cell in this row?

Post by Colo » Fri, 16 Apr 2004 14:17:06

Amolin, SelectionChange event makes this possible as follow.
If you have already colored cell in the wks, need more code.
Please note, this is just a sample code.


Code
-------------------

'Wks Module
Dim preservedRange As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not preservedRange Is Nothing Then
preservedRange.Interior.ColorIndex = xlNone
End If
Target.EntireRow.Cells.Interior.ColorIndex = 10
Set preservedRange = Target.EntireRow
End Sub

-------------------

 
 
 

How to change row color when select a cell in this row?

Post by Frank Kabe » Fri, 16 Apr 2004 14:54:42

Hi
have a look at
http://www.yqcomputer.com/ #HighlightActiveCell
http://www.yqcomputer.com/


--
Regards
Frank Kabel
Frankfurt, Germany
 
 
 

How to change row color when select a cell in this row?

Post by Robert McC » Sun, 18 Apr 2004 20:11:00

Hi Amolin try this, the other colours are saved and not overwritten when you select another row. If you need more columns than 26
increase this number in the code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Highlights the active row to column Z
Static c As Excel.Range, Rng As Excel.Range
Static n(26), x As Integer
x = 35
Dim i As Integer
Application.ScreenUpdating = False
If Not c Is Nothing Then
If c.Row = ActiveCell.Row Then Exit Sub
For i = 1 To 26
Rng.Cells(i).Interior.ColorIndex = n(i)
Next i
End If
Set c = ActiveCell
Set Rng = Range(Cells(c.Row, 1), Cells(c.Row, 26))
For i = 1 To 26
n(i) = Rng.Cells(i).Interior.ColorIndex
Next i
Rng.Interior.ColorIndex = x
End Sub


Regards Robert




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.yqcomputer.com/ ).
Version: 6.0.655 / Virus Database: 420 - Release Date: 08/04/2004