Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default Highlighting row of active cell question

Hi,
Im using the code below to highlight the row of the active cell, but if you
click in the highlighted row again it loses its highlight.
What I need is some form of code I think to say €śIf the new active cell is
in the same row as the old cell, keep the highlight€ť €“ Im just not good
enough at VBA to write it!


'Highlights the active cell row
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Excel.Range)
Static OldRng As Range
On Error Resume Next
Target.EntireRow.Interior.ColorIndex = 6
OldRng.EntireRow.Interior.ColorIndex = xlColorIndexNone
Set OldRng = Target
End Sub

Any ideas?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Highlighting row of active cell question

Hi,

Try this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target
With .EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
.Interior.ColorIndex = 20
End With
End With
..FormatConditions.Delete
..FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
End With
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"KevHardy" wrote:

Hi,
Im using the code below to highlight the row of the active cell, but if you
click in the highlighted row again it loses its highlight.
What I need is some form of code I think to say €śIf the new active cell is
in the same row as the old cell, keep the highlight€ť €“ Im just not good
enough at VBA to write it!


'Highlights the active cell row
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Excel.Range)
Static OldRng As Range
On Error Resume Next
Target.EntireRow.Interior.ColorIndex = 6
OldRng.EntireRow.Interior.ColorIndex = xlColorIndexNone
Set OldRng = Target
End Sub

Any ideas?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default Highlighting row of active cell question

Thanks Mike. Works a treat!

"Mike H" wrote:

Hi,

Try this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target
With .EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
.Interior.ColorIndex = 20
End With
End With
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
End With
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"KevHardy" wrote:

Hi,
Im using the code below to highlight the row of the active cell, but if you
click in the highlighted row again it loses its highlight.
What I need is some form of code I think to say €śIf the new active cell is
in the same row as the old cell, keep the highlight€ť €“ Im just not good
enough at VBA to write it!


'Highlights the active cell row
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Excel.Range)
Static OldRng As Range
On Error Resume Next
Target.EntireRow.Interior.ColorIndex = 6
OldRng.EntireRow.Interior.ColorIndex = xlColorIndexNone
Set OldRng = Target
End Sub

Any ideas?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Highlighting row of active cell question

Glad I could help and thanks for the feedback
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"KevHardy" wrote:

Thanks Mike. Works a treat!

"Mike H" wrote:

Hi,

Try this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target
With .EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
.Interior.ColorIndex = 20
End With
End With
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
End With
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"KevHardy" wrote:

Hi,
Im using the code below to highlight the row of the active cell, but if you
click in the highlighted row again it loses its highlight.
What I need is some form of code I think to say €śIf the new active cell is
in the same row as the old cell, keep the highlight€ť €“ Im just not good
enough at VBA to write it!


'Highlights the active cell row
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Excel.Range)
Static OldRng As Range
On Error Resume Next
Target.EntireRow.Interior.ColorIndex = 6
OldRng.EntireRow.Interior.ColorIndex = xlColorIndexNone
Set OldRng = Target
End Sub

Any ideas?

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
Cell highlighting question gootroots Excel Worksheet Functions 4 November 17th 09 05:21 AM
Highlighting the active cell during "Find" joflo65 Excel Discussion (Misc queries) 0 September 19th 08 05:54 PM
Highlighting Active Cell jpreman Excel Discussion (Misc queries) 0 January 23rd 08 01:49 AM
Highlighting Active Cell? How? skint Excel Discussion (Misc queries) 2 October 9th 06 01:06 AM
Highlighting an active cell pjy Excel Worksheet Functions 1 August 2nd 06 05:36 PM


All times are GMT +1. The time now is 02:25 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"