Macro to delete row after certain condition found [Solved/Closed]

Posts
4
Registration date
Thursday April 3, 2014
Status
Member
Last seen
April 4, 2014
- - Latest reply: wendelly
Posts
4
Registration date
Thursday April 3, 2014
Status
Member
Last seen
April 4, 2014
- Apr 4, 2014 at 03:23 PM
Hello,

I am an Excel newbie; I am trying to write an Excel macro that will search a certain column to find a blank value. It would then delete the row immediately after the row that contains the blank column value, cycling through the entire file. Any help would be much appreciated, thanks.

See more 

5 replies

Best answer
Posts
7239
Registration date
Saturday April 7, 2007
Status
Moderator
Last seen
October 31, 2019
488
1
Thank you
I presumed that there were titles on the Row 1, put this macro on the sheet you want to use it, in VBA project :
Public Sub DeleteRowIfCellZero_ColD()
Dim x As Long
Dim y As Long
x = Range("D65536").End(xlUp).Row

For y = x To 2 Step -1

    If Cells(y, 4).Value = 0 Then
    
        Rows(y + 1).EntireRow.Delete
    
    End If

Next y
End Sub


Regards

Say "Thank you" 1

A few words of thanks would be greatly appreciated. Add comment

CCM 6075 users have said thank you to us this month

Posts
7239
Registration date
Saturday April 7, 2007
Status
Moderator
Last seen
October 31, 2019
488
0
Thank you
Hello,

Which column? Everytime the same column or not?

Regards
Posts
4
Registration date
Thursday April 3, 2014
Status
Member
Last seen
April 4, 2014
0
Thank you
Hello, it would be the same column every time. Thanks.
aquarelle
Posts
7239
Registration date
Saturday April 7, 2007
Status
Moderator
Last seen
October 31, 2019
488 -
Which? A B C...?
Posts
4
Registration date
Thursday April 3, 2014
Status
Member
Last seen
April 4, 2014
0
Thank you
It would be column D.
Posts
4
Registration date
Thursday April 3, 2014
Status
Member
Last seen
April 4, 2014
0
Thank you
That worked brilliantly. Thanks.