#1   Report Post  
Bob Phillips
 
Posts: n/a
Default highlight row

If you already have a conditional format, this is problemmatical. I once
tried to work it to add a condition, but it was slow and convoluted.

An alternative is to use normal colouring, as shown below. This will wipe
out any standard colouring or borders that you may have, so if this is a
problem another way is to add a shape over the row as Chip does here
http://www.cpearson.com/excel/RowLiner.htm

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
With Cells
With .Borders(xlTop)
.LineStyle = xlLineStyleNone
.ColorIndex = xlColorIndexNone
End With
With .Borders(xlBottom)
.LineStyle = xlLineStyleNone
.ColorIndex = xlColorIndexNone
End With
.Interior.ColorIndex = xlColorIndexNone
End With
If Not Intersect(Target, Range("2:20")) Is Nothing Then
With Target
With .EntireRow
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With

.Interior.ColorIndex = 36
End With
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Benjamin" wrote in message
...
I think I spoke too soon. This works fine, except it seems to interfere

with
a conditional format I have outside of the area I have the macro working.
Conditional format is based on values wihtin the area the macro runs. Any
ideas?

"Benjamin" wrote:

Works perfect. Thanks again.

"Bob Phillips" wrote:

Ben,

Here is an alternate. It test for rows 2:20, which you can adjust to

suit

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
If Not Intersect(Target, Range("2:20")) Is Nothing Then
With Target
With .EntireRow
.FormatConditions.Add Type:=xlExpression,

Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With
End With

.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With
End If
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Benjamin" wrote in message
...
Thanks Bob! Two issues though. Any way to highlight only the row

and not
the column? And how could I limit this code to execute only within a
specific
range?

Ben

"Bob Phillips" wrote:


'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
With .EntireRow
.FormatConditions.Add Type:=xlExpression,

Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With
End With
With .EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression,

Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
.Interior.ColorIndex = 20
End With
End With

.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

RP
(remove nothere from the email address if mailing direct)


"Benjamin" wrote in message
...
Is there any way to have excel automatically highlight the row

of a
selected
cell ?

TIA

Ben








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formulas to highlight cell if condition is met hmmm Excel Discussion (Misc queries) 2 November 3rd 05 10:09 AM
Highlight all colums in Bar Graph Parveen Charts and Charting in Excel 1 October 29th 05 02:15 PM
Conditional Format to highlight entrire Row shital shah Excel Worksheet Functions 1 August 25th 05 03:44 PM
highlight cells equals sum, not count PTFisher Excel Discussion (Misc queries) 2 June 4th 05 07:12 PM
How can I highlight every other group of data? Brandie Excel Discussion (Misc queries) 1 May 27th 05 06:26 PM


All times are GMT +1. The time now is 08:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"