ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Invalid Dates records to separate worksheet (https://www.excelbanter.com/excel-programming/396839-copy-invalid-dates-records-separate-worksheet.html)

u473

Copy Invalid Dates records to separate worksheet
 
How do I copy, for invalid date or date gretar than today, the Entire
row to the InvalidDates Worksheet
Looking for proper syntax. Help appreciated.

Dim rCell As Range
Dim myRow As Long
For Each rCell In Range("Z2:Z" & _
Range("Z" & Rows.Count).End(xlUp).Row)
With rCell
If IsDate(.Value) Then _
.Offset(0, -1).Value = Right(Format(.Value, "YYMM"),
3)
'If Date is greater than Today, Copy Entire row to
Invalid Dates worksheet & Delete Entire Row
'If ActiveCell.Value Now()
' myRow =
Sheets("InvalidDates").Cells(Rows.Count, 3).End(xlUp)(2).Row
' Intersect(Target.EntireRow,
ActiveSheet.UsedRange).Copy
' Entire.row.Delete
Else
' myRow =
Sheets("InvalidDates").Cells(Rows.Count, 3).End(xlUp)(2).Row
' Intersect(Target.EntireRow,
ActiveSheet.UsedRange).Copy
'.Entire.row.Delete
End If

End With
Next rCell


Don Guillett

Copy Invalid Dates records to separate worksheet
 
Sub copyinvaliddates()
For Each c In Range("a24:a26")
With Sheets("sheet7")
lr = .Cells(Rows.Count, "a").End(xlUp).Row + 1
If Not IsDate(c) Or c Date Then _
Rows(c.Row).Copy .Cells(lr, 1)
End With
Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"u473" wrote in message
ups.com...
How do I copy, for invalid date or date gretar than today, the Entire
row to the InvalidDates Worksheet
Looking for proper syntax. Help appreciated.

Dim rCell As Range
Dim myRow As Long
For Each rCell In Range("Z2:Z" & _
Range("Z" & Rows.Count).End(xlUp).Row)
With rCell
If IsDate(.Value) Then _
.Offset(0, -1).Value = Right(Format(.Value, "YYMM"),
3)
'If Date is greater than Today, Copy Entire row to
Invalid Dates worksheet & Delete Entire Row
'If ActiveCell.Value Now()
' myRow =
Sheets("InvalidDates").Cells(Rows.Count, 3).End(xlUp)(2).Row
' Intersect(Target.EntireRow,
ActiveSheet.UsedRange).Copy
' Entire.row.Delete
Else
' myRow =
Sheets("InvalidDates").Cells(Rows.Count, 3).End(xlUp)(2).Row
' Intersect(Target.EntireRow,
ActiveSheet.UsedRange).Copy
'.Entire.row.Delete
End If

End With
Next rCell




All times are GMT +1. The time now is 03:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com