Hi,
I'm trying to get a code to automatically move a row to another sheet when a date is entered. This is very new to me but I've been searching for days and have some kind of code that is bringing up a run-time error '1004'. This also highlights the Set rngTrigger line. Hopefully someone can help.
Code so far;
Thanks in advance
I'm trying to get a code to automatically move a row to another sheet when a date is entered. This is very new to me but I've been searching for days and have some kind of code that is bringing up a run-time error '1004'. This also highlights the Set rngTrigger line. Hopefully someone can help.
Code so far;
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngTrigger As Range
Dim rngDest As Range
Set rngTrigger = Sheets("Test1").Range("rngTrigger")
Set rngDest = Sheets("Test2").Range("rngDest")
' Limit the trap area to range of cells in which completed dates are entered as defined above
If Not Intersect(Target, Sheet1.Range("rngTrigger")) Is Nothing Then
' Only trigger if the value entered is a date or is recognizable as a valid date
If IsDate(Target) Then
'Ensure subsequent deletion of 'moved' row does NOT cause the Change Event to run again and get itself in a loop!
Application.EnableEvents = False
Target.EntireRow.Select
Selection.Cut
rngDest.Insert Shift:=xlDown
Selection.delete
' Reset EnableEvents
Application.EnableEvents = True
End If
End If
End Sub
Last edited by a moderator: