Macro - delete rows based on date

前端 未结 4 1697
北恋
北恋 2020-12-17 07:36

I am very new to VBA and macros in Excel. I have a very large excel spreadsheet in which column A holds dates. I am trying to delete the rows which have a value smaller than

4条回答
  •  不知归路
    2020-12-17 08:03

    Please try with this

    Sub DELETEDATE()
    Dim x As Long
    last = Range("A65536").End(xlUp).Row
    For x = 1 To last
        Debug.Print Cells(x, "A").Value
        check:
        If x <= last Then
            If Trim(CDate(Cells(x, "A"))) <= Trim(CDate("7/29/2013")) Then
                last = last - 1
                Cells(x, "A").EntireRow.Delete
                GoTo check
            End If
        End If
    Next x
    End Sub
    

提交回复
热议问题