Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default highlight of a range

I have a spreadsheet that has several hundred rows and 25 columns of info. I
would like to be able to highlight the entire row of information that the
cursur is in and the highlighted row moves as the cursur moves. I am not
sure how to do this please help

thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default highlight of a range

right click on the sheet tab and select view code

paste in code like this:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object,
ByVal Target As Excel.Range)
Static OldRange As Range
On Error Resume Next
Target.Entirerow.Interior.ColorIndex = 6 ' yellow - change as needed
OldRange.EntireRow.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target

End Sub

Adapted from code by Chip Pearson.

http://www.cpearson.com/excel/excelM...ightActiveCell

--
Regards,
Tom Ogilvy

"shawn" wrote in message
...
I have a spreadsheet that has several hundred rows and 25 columns of info.

I
would like to be able to highlight the entire row of information that the
cursur is in and the highlighted row moves as the cursur moves. I am not
sure how to do this please help

thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default highlight of a range

Tom Ogilvy wrote

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object,
ByVal Target As Excel.Range)
Static OldRange As Range
On Error Resume Next
Target.Entirerow.Interior.ColorIndex = 6 ' yellow - change as needed
OldRange.EntireRow.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target

End Sub


Can you help me adapt your seemingly more efficient method to a limited
range of cells?

Code I currently use:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("I5:S55").FormatConditions.Delete
If Intersect(Target, Range("I5:S55")) Is Nothing Then Exit Sub
With Range(Cells(Target.Row, 9), Cells(Target.Row, 19))
..FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
..FormatConditions(1).Interior.ColorIndex = 6
End With
End Sub

--
David
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default highlight of a range

David wrote

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("I5:S55").FormatConditions.Delete
If Intersect(Target, Range("I5:S55")) Is Nothing Then Exit Sub
With Range(Cells(Target.Row, 9), Cells(Target.Row, 19))
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 6
End With
End Sub


Was able to reduce to this:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("I5:S55").Interior.ColorIndex = 2
If Intersect(Target, Range("I5:S55")) Is Nothing Then Exit Sub
Range(Cells(Target.Row, 9), Cells(Target.Row, 19)).Interior.ColorIndex = 6
End Sub

Works as desired.

--
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
how do i highlight the ten highest numbers in a range? Help Wanted Excel Discussion (Misc queries) 3 May 5th 09 06:39 PM
highlight the cell based on the range for a given value Narnimar Excel Discussion (Misc queries) 7 December 26th 07 02:43 PM
Highlight a range for data entry Kirk P. Excel Discussion (Misc queries) 2 August 28th 06 03:09 PM
Macro to Highlight Range LLoraine Excel Discussion (Misc queries) 2 April 19th 06 02:41 PM
want highlight when all cells in range are equal Jane Excel Worksheet Functions 4 November 16th 05 01:53 AM


All times are GMT +1. The time now is 11:49 PM.

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"