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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 11:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com