Delete entire row based on two conditions

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
882
Hi all, i would like to use VBA code so that to delete entire row if met two criteria. Col."H" is 0 (zero) and col. "N" is blank.

Thank you all in advance
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Code:
Option Explicit


Sub Panoos()
    Dim i As Long, lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    For i = lr To 1 Step -1
        If Range("H" & i) = 0 Then
            If IsNull(Range("N" & i)) Then
                Range("H" & i).EntireRow.Delete
            End If
        End If
    Next i
End Sub
 
Upvote 0
Hi alan, it doesn't work. If Col. "H" contains number "0" and col. "N" is blank then should delete entire row. However thank you for your support. Have a great day
 
Upvote 0
What does Blank in Column N mean? Does it contain a formula? If it contains a formula then it is not blank by Excel standards. Blank is Null. No formula. No nothing. Your response of "doesn't work" doesn't help me to solve your issue. Suggest you upload your file (sample) to a third party web site for analysis as without seeing what "Blank" means I can offer no further help. My Code works for me.
 
Upvote 0
If i have understood your problem
Try with this code
Code:
Option Explicit


Sub Panoos()
    Dim last As Long, i As Integer
    Application.ScreenUpdating = False
    last = Cells(Rows.Count, "H").End(xlUp).Row
    For i = last To 2 Step -1
        If (Cells(i, "H").Value = 0) And (Cells(i, "N") = "") Then
            Rows(i).Delete
        End If
   Next i
    Application.ScreenUpdating = True
End Sub

Regards
Dhruv
 
Last edited:
Upvote 0
Thank you Girish, it works perfect and nicely. Thank you once again for your time spent for my project. Have a lovely day!
 
Upvote 0
Hi alan, i do know the reason that it doesn't work. No formula exists in "N" in blank cells and col. "H" contains the "0" number. Do not worry about and appreciated what you done for me. However Girish code works perfect but i couldn't find the differences between yours and his code. Thank you once again for your support.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

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