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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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,215,514
Messages
6,125,273
Members
449,219
Latest member
daynle

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