Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Highlight rows


I would like to make the entire row background color yellow when checked.





Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("A1:A100")) Is Nothing Then
With Target
If .Value = "a" Then
.Value = ""
Else
.Value = "a"
.Font.Name = "Marlett"
&! nbsp; End If
End With
End If
sub_exit:
Application.EnableEvents = True
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Highlight rows

Hi Randy
try
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("A1:A100")) Is Nothing Then
With Target
If .Value = "a" Then
.Value = ""
Else
.Value = "a"
.entirerow.interior.colorindex= 6
.Font.Name = "Marlett" &! nbsp;
End If
End With
End If
sub_exit:
Application.EnableEvents = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany
"Randy Reese" schrieb im Newsbeitrag
ink.net...

I would like to make the entire row background color yellow when

checked.





Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("A1:A100")) Is Nothing Then
With Target
If .Value = "a" Then
.Value = ""
Else
.Value = "a"
.Font.Name = "Marlett"
&! nbsp; End If
End With
End If
sub_exit:
Application.EnableEvents = True
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Highlight rows


-----Original Message-----

I would like to make the entire row background color

yellow when checked.





Private Sub Worksheet_SelectionChange(ByVal Target As

Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("A1:A100")) Is Nothing

Then
With Target
If .Value = "a" Then
.Value = ""
Else
.Value = "a"
.Font.Name = "Marlett"
&! nbsp; End If
End With
End If
sub_exit:
Application.EnableEvents = True
End Sub


.
By setting EnableEvents to false at the beggining of your

procedure you have disabled your code since you are using
the SelectionChange event of the worksheet.
SelectionChange is of course an event by definition and
you have turned it off by setting EnableEvents to false.
Don't set EnableEvents to false and that should fix your
problem..
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Highlight rows

Hi
I don't see a problem as the events are enabled again at the end of
this code (also in case of an error)

--
Regards
Frank Kabel
Frankfurt, Germany
"B.Dryden" schrieb im Newsbeitrag
...

-----Original Message-----

I would like to make the entire row background color

yellow when checked.





Private Sub Worksheet_SelectionChange(ByVal Target As

Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("A1:A100")) Is Nothing

Then
With Target
If .Value = "a" Then
.Value = ""
Else
.Value = "a"
.Font.Name = "Marlett"
&! nbsp; End If
End With
End If
sub_exit:
Application.EnableEvents = True
End Sub


.
By setting EnableEvents to false at the beggining of your

procedure you have disabled your code since you are using
the SelectionChange event of the worksheet.
SelectionChange is of course an event by definition and
you have turned it off by setting EnableEvents to false.
Don't set EnableEvents to false and that should fix your
problem..


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Highlight rows

Thanks Frank, works good.
Is there a way to keep my grid or redraw after highlight??

"Frank Kabel" wrote in message
...
Hi
I don't see a problem as the events are enabled again at the end of
this code (also in case of an error)

--
Regards
Frank Kabel
Frankfurt, Germany
"B.Dryden" schrieb im Newsbeitrag
...

-----Original Message-----

I would like to make the entire row background color

yellow when checked.





Private Sub Worksheet_SelectionChange(ByVal Target As

Range)
Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("A1:A100")) Is Nothing

Then
With Target
If .Value = "a" Then
.Value = ""
Else
.Value = "a"
.Font.Name = "Marlett"
&! nbsp; End If
End With
End If
sub_exit:
Application.EnableEvents = True
End Sub


.
By setting EnableEvents to false at the beggining of your

procedure you have disabled your code since you are using
the SelectionChange event of the worksheet.
SelectionChange is of course an event by definition and
you have turned it off by setting EnableEvents to false.
Don't set EnableEvents to false and that should fix your
problem..




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
more rows highlight than I want ren Excel Discussion (Misc queries) 1 March 14th 10 10:02 AM
highlight duplicate rows James Excel Discussion (Misc queries) 4 October 10th 08 02:43 PM
Highlight rows Scott R Excel Worksheet Functions 5 December 5th 07 01:19 AM
Can I highlight all the odd rows in Excel? paulkc Excel Discussion (Misc queries) 1 November 21st 05 01:46 PM
Any way to highlight rows without using macros? Spalding Excel Discussion (Misc queries) 2 November 9th 05 03:12 PM


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