Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default combine change event codes

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: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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default combine change event codes

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: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

"J.W. Aldridge" wrote in message
oups.com...
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: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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default combine change event codes

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" wrote in message
oups.com...
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: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
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
enableevents in event codes R..VENKATARAMAN Excel Programming 2 April 27th 06 06:13 AM
need programming help with nested event codes timber Excel Programming 1 April 6th 06 05:33 PM
MsgBox in Enter event causes combobox not to run Change event Richard Excel Programming 0 March 6th 06 02:52 PM
Linking worksheet event codes Mr. G. Excel Worksheet Functions 7 July 15th 05 06:15 PM


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