View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default How to change entire row colour when row is selected?

Something like this, so only the first row is changed, if you select
multiple rows:

Dim OldRange As Range

Private Sub Worksheet_Activate()
Set OldRange = ActiveCell.Range("A1")
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Clear the old formatting
With OldRange.EntireRow.Font
.ColorIndex = xlAutomatic
.Bold = False
End With
'Set the new formatting
With Target.Range("A1").EntireRow.Font
.ColorIndex = 3
.Bold = True
End With
'Reset the range
Set OldRange = Target.Range("A1")
End Sub

NickHK

wrote in message
oups.com...
That would certainly work but I need to perform the function for many
rows and many columns, so I want some user friendly code that won't
require to much repetition, which is why I want a use an else
statement.

I bascially need some code so that when row 4 is selected, all text in
row 4 is made bold and red, while the text in ALL other rows is made
black and unbold. The, if row 7 is selected, all the text in row 7 is
made bold and red, while the text in ALL other rows is made black and
unbold.

Does anybody know how to perform this?