Trying to move a row to another sheet if a date is entered in excel

Janet215

New Member
Joined
Feb 11, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am using the code below and it's moving the row when I enter non-date entries. If I enter text, it moves the row. I only want it to move if there is a date in it. It doesn't matter what date, but it has to be a date.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 And Target.Cells.Count = 1 Then
If Target.Value > Date - 10000 Then
With Target.EntireRow
.Copy Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.Delete
End With
End If
End If
End Sub

Thanks!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 And Target.Cells.Count = 1 Then
If IsDate(Target.Value) Then
With Target.EntireRow
.Copy Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.Delete
End With
End If
End If
End Sub
 
Upvote 0
Glad to help and thanks for the feedback !!
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,172
Members
448,870
Latest member
max_pedreira

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