VBA- Delete a specific row with text+delete the row before+ delete the row after

tzav

New Member
Joined
Sep 5, 2022
Messages
16
Office Version
  1. 2010
Platform
  1. Windows
Hi,

I need to delete with VBA every row that contains the value "00/00/0000"+ one row before and one row after (3 rows in total).
the values are in column m.

For example:
row 1
row 2
row 3- 00/00/0000
row 4
row 5
row 6- 00/00/0000
row 7
row 8
etc...

In this example, the result needs to be that only rows 1+8 stay.

Thanks
 
Updating igold's code like this should do what you want:
VBA Code:
Sub DeleteZeroDates()

    Dim i  As Long
   
    For i = Cells(Rows.Count, 13).End(xlUp).Row To 1 Step -1
        If Right(Trim(Cells(i, 13)), 10) = "00/00/0000" Then
            Cells(i - 1, 13).Resize(3).EntireRow.Delete
        End If
    Next
   
End Sub
It worked!
Thanks to both of you
 
Upvote 0

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
You're welcome. We were both happy to help. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,631
Messages
6,125,905
Members
449,273
Latest member
mrcsbenson

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