2 on change actions

jtodd

Board Regular
Joined
Aug 4, 2014
Messages
194
Hi , is it possible to have 2 actions on the worksheet change - i have the folowing code
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myTableRange As Range
Dim myDateTimeRange As Range
'Dim myUpdateRange As Range

Set myTableRange = Range("K:K")
If Intersect(Target, myTableRange) Is Nothing Then Exit Sub
Set myDateTimeRange = Range("L" & Target.Row)
'Set myUpdatedRange = Range("L" & Target.Row)

If myDateTimeRange.Value = "" Then
   myDateTimeRange.Value = Now
   End If
End Sub
this works fine but is it possible to also have it do the same for Range G:G and target row H
 
Last edited by a moderator:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myTableRange As Range
Dim myDateTimeRange As Range
'Dim myUpdateRange As Range

Set myTableRange = Range("K:K")
If Not Intersect(Target, myTableRange) Is Nothing Then
   Set myDateTimeRange = Range("L" & Target.Row)
   'Set myUpdatedRange = Range("L" & Target.Row)
   
   If myDateTimeRange.Value = "" Then
      myDateTimeRange.Value = Now
   End If
ElseIf Not Intersect(Target, Range("G:G")) Is Nothing Then
   If Target.Offset(, 1).Value = "" Then Target.Offset(, 1).Value = Now
End If
End Sub
 
Upvote 0
Thanks for quick reply - when i add this code i get the following error
1636639653063.png
 
Upvote 0
Delete your code & then copy/paste the code I supplied.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top