Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Delete rows if contain specific value in column with vba I have a column L with

ID: 643229 • Letter: D

Question

Delete rows if contain specific value in column with vba

I have a column L with different dates I need delete row that contain dates greater and equals than today with vba. I have the below code but not work correctly. Help with this code

Sub DeleteDates()
Dim r As Long
Dim m As Long

    Set ws = Worksheets("Sheet1")

    m = ws.Range("L" & ws.Rows.Count).End(xlUp).Row
  
    For r = m To 2 Step -1
     
            If ws.Range("L" & r).Value >= Date - 1 Then
            
             ws.Rows(r).delete
          
        End If
    Next r

End Sub

Thanks for help !!

Explanation / Answer

Hi..

I don't see any problem with your code except you should remove -1 in the below code

If ws.Range("L" & r).Value >= Date - 1 Then   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote