Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
David
 
Posts: n/a
Default Restrict Highlighting?

I've seen this from Bob Phillips:

'-----------------------------*------------------------------*-----
Private Sub WorkSheet_SelectionChange(ByVa*l Target As Range)
'-----------------------------*------------------------------*-----


Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.*ColorIndex = 35
End With
With Target.EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.*ColorIndex = 35
End With
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.*ColorIndex = 36
End With


End Sub

How can I restrict it to specific range - Range("J5:S55")

--
David
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

'-----------------------------*------------------------------*-----
Private Sub WorkSheet_SelectionChange(ByVal Target As Range)
'-----------------------------*------------------------------*-----

If Not Intersect(Target, Me.Range("J5:S55")) Is Nothing Then
Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
With Target.EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
With Target
.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)


"David" wrote in message
...
I've seen this from Bob Phillips:

'-----------------------------*------------------------------*-----
Private Sub WorkSheet_SelectionChange(ByVa*l Target As Range)
'-----------------------------*------------------------------*-----


Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.*ColorIndex = 35
End With
With Target.EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.*ColorIndex = 35
End With
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.*ColorIndex = 36
End With


End Sub

How can I restrict it to specific range - Range("J5:S55")

--
David



  #3   Report Post  
David
 
Posts: n/a
Default

Bob Phillips wrote

'-----------------------------ð------------------------------ð-----
Private Sub WorkSheet_SelectionChange(ByVal Target As Range)
'-----------------------------ð------------------------------ð-----

If Not Intersect(Target, Me.Range("J5:S55")) Is Nothing Then
Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
With Target.EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With
End If

End Sub


Thanks for the quick reply. Still highlights entire row and column of
Target, though. Guess I should have said restrict *within* Range
("J5:S55")

Anyway, I was able to modify with my existing code (I have some other
conditions that need to be satisfied) and came up with:

Range("I5:S55").Interior.ColorIndex = xlNone
If Intersect(Target, Range("J5:S55")) Is Nothing Then Exit Sub
Range(Cells(Target.Row, 9), Cells(Target.Row, 19)).Interior.ColorIndex =
35
Range(Cells(5, Target.Column), Cells(55, _
Target.Column)).Interior.ColorIndex = 35
ActiveCell.Interior.ColorIndex = 36

Seems to do the trick.

--
David
  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

I don't like coding those cells more than you have to.

You didn't say you didn't want the whole row and column, just restrict it.

If J5 was selected, what should be highlighted? etc.

--

HTH

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


"David" wrote in message
...
Bob Phillips wrote

'-----------------------------ð------------------------------ð-----
Private Sub WorkSheet_SelectionChange(ByVal Target As Range)
'-----------------------------ð------------------------------ð-----

If Not Intersect(Target, Me.Range("J5:S55")) Is Nothing Then
Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
With Target.EntireColumn
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With
End If

End Sub


Thanks for the quick reply. Still highlights entire row and column of
Target, though. Guess I should have said restrict *within* Range
("J5:S55")

Anyway, I was able to modify with my existing code (I have some other
conditions that need to be satisfied) and came up with:

Range("I5:S55").Interior.ColorIndex = xlNone
If Intersect(Target, Range("J5:S55")) Is Nothing Then Exit Sub
Range(Cells(Target.Row, 9), Cells(Target.Row, 19)).Interior.ColorIndex =
35
Range(Cells(5, Target.Column), Cells(55, _
Target.Column)).Interior.ColorIndex = 35
ActiveCell.Interior.ColorIndex = 36

Seems to do the trick.

--
David



  #5   Report Post  
David
 
Posts: n/a
Default

Bob Phillips wrote

I don't like coding those cells more than you have to.

You didn't say you didn't want the whole row and column, just restrict
it.

If J5 was selected, what should be highlighted? etc.


Sorry, I'm still learning how to post my needs clearly. I never seem to get
it right the first time 8-(

--
David
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
Cells in Excel will not stop highlighting Boe Excel Discussion (Misc queries) 3 June 14th 05 03:53 PM
How do I restrict only 1 of 2 check boxes be checked? Board Excel Discussion (Misc queries) 3 May 17th 05 06:47 PM
Help with Highlighting all duplicates in a row Jimv Excel Discussion (Misc queries) 4 April 21st 05 07:12 PM
Restrict input if amount is exceeded Der Musensohn Excel Worksheet Functions 1 April 8th 05 11:33 PM
restrict opening Excel file residing on a shared drive to one user k-ham Excel Discussion (Misc queries) 1 January 7th 05 01:57 AM


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

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

About Us

"It's about Microsoft Excel"