PC Review


Reply
Thread Tools Rate Thread

combine change event codes

 
 
J.W. Aldridge
Guest
Posts: n/a
 
      20th Jan 2007
HI.
I seem to have a problem.........

Anytime I attempt to add an additional (change event) code to a
worksheet, it seems to go haywire.
(Is there somekind of rule that you cant have two separate change
events triggering at the same time?)

So,
Could someone help me to combine the following two event codes?

First one gives me my date and time stamp.
Second one forces upper case on a particular row.

__________________
#1
Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit

If Not Intersect(Target, Me.Columns(3)) Is Nothing Then
Me.Range("B" & Target.Row).Value = Time
End If
Me.Range("A" & Target.Row).Value = Date

ws_exit:
Application.EnableEvents = True
On Error GoTo 0
End Sub

___________________________________________________
#2
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Error_handler
If Not Intersect(Range("D"), Target) Is Nothing Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
.Value = UCase(.Value)
End If
End With
End If


Error_handler:
Resume Next
Application.EnableEvents = True


End Sub

 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      20th Jan 2007
You can only have one of each type event. Either use a different event or
combine. Here is the idea but you need to clean it up some more.

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit

If Not Intersect(Target, Me.Columns(3)) Is Nothing Then
Me.Range("B" & Target.Row).Value = Time
End If
Me.Range("A" & Target.Row).Value = Date

'#2
If Not Intersect(Range("D"), Target) Is Nothing Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
.Value = UCase(.Value)
End If
End With
End If

ws_exit:
Application.EnableEvents = True
On Error GoTo 0
End Sub

___________________________________________________


--
Don Guillett
SalesAid Software
(E-Mail Removed)
"J.W. Aldridge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HI.
> I seem to have a problem.........
>
> Anytime I attempt to add an additional (change event) code to a
> worksheet, it seems to go haywire.
> (Is there somekind of rule that you cant have two separate change
> events triggering at the same time?)
>
> So,
> Could someone help me to combine the following two event codes?
>
> First one gives me my date and time stamp.
> Second one forces upper case on a particular row.
>
> __________________
> #1
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> Application.EnableEvents = False
> On Error GoTo ws_exit
>
> If Not Intersect(Target, Me.Columns(3)) Is Nothing Then
> Me.Range("B" & Target.Row).Value = Time
> End If
> Me.Range("A" & Target.Row).Value = Date
>
> ws_exit:
> Application.EnableEvents = True
> On Error GoTo 0
> End Sub
>
> ___________________________________________________
> #2
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo Error_handler
> If Not Intersect(Range("D"), Target) Is Nothing Then
> With Target
> If Not .HasFormula Then
> Application.EnableEvents = False
> .Value = UCase(.Value)
> End If
> End With
> End If
>
>
> Error_handler:
> Resume Next
> Application.EnableEvents = True
>
>
> End Sub
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      20th Jan 2007
Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit

Me.Range("A" & Target.Row).Value = Date
If Not Intersect(Target, Me.Columns(3)) Is Nothing Then
Me.Range("B" & Target.Row).Value = Time
ElseIf Not Intersect(Target, Me.Columns(4)) Is Nothing Then
With Target
If Not .HasFormula Then
.Value = UCase(.Value)
End If
End With
End If

ws_exit:
Application.EnableEvents = True
On Error GoTo 0
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"J.W. Aldridge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HI.
> I seem to have a problem.........
>
> Anytime I attempt to add an additional (change event) code to a
> worksheet, it seems to go haywire.
> (Is there somekind of rule that you cant have two separate change
> events triggering at the same time?)
>
> So,
> Could someone help me to combine the following two event codes?
>
> First one gives me my date and time stamp.
> Second one forces upper case on a particular row.
>
> __________________
> #1
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> Application.EnableEvents = False
> On Error GoTo ws_exit
>
> If Not Intersect(Target, Me.Columns(3)) Is Nothing Then
> Me.Range("B" & Target.Row).Value = Time
> End If
> Me.Range("A" & Target.Row).Value = Date
>
> ws_exit:
> Application.EnableEvents = True
> On Error GoTo 0
> End Sub
>
> ___________________________________________________
> #2
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo Error_handler
> If Not Intersect(Range("D"), Target) Is Nothing Then
> With Target
> If Not .HasFormula Then
> Application.EnableEvents = False
> .Value = UCase(.Value)
> End If
> End With
> End If
>
>
> Error_handler:
> Resume Next
> Application.EnableEvents = True
>
>
> End Sub
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Codes to combine PDF files =?Utf-8?B?c2FsdXQ=?= Microsoft Excel Programming 3 2nd Dec 2009 03:03 AM
Combine 2 worksheet event change codes winnie123 Microsoft Excel Programming 4 19th Oct 2009 05:54 AM
Please help combine two simple codes! J.W. Aldridge Microsoft Excel Programming 3 17th Apr 2009 04:22 PM
Combine 2 Codes into 1 Code to do the lot? Corey Microsoft Excel Programming 2 18th Sep 2008 09:19 AM
combine codes =?Utf-8?B?TGV2YW5zIGRpZ2l0YWw=?= Microsoft Access VBA Modules 5 19th Jun 2006 04:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:24 PM.