I have researched several codes but it's either for blanks only or zeroes only, and I need a code for both blanks and zeroes.
I have 3 columns to note if this should be deleted or not
I need to delete the rows with complete details(ID, and Address)(the Name is the basis for the details), since I need the rows with incomplete details(ID or Address as zeroes or blanks) to retain.
ID Name Address 1 A 123 ABC 2 B 0 C 345 CDE D 5 E 567 EFG 0 F 678 FGH 7 G 789 GHI 0 H 0 My first try was this code, it works for the conditions, but if I have succeeding blanks, it skips the next row, since that row goes up
lrow = 1000 For x = 2 To lrow If Cells(x,2)<>"" Then If Cells(x,1) <> "" Or Cells(x,1) <> "0" Or Cells(x,3) <> "" Or Cells(x,3) <> "0" Then Cells(x,11).EntireRow.Delete End If End If Next x So I tried this code, where I start from bottom to up.
lrow = 1000 For x = lrow To 2 Step -1 If Cells(x,2)<>"" Then If Cells(x,1) <> "" Or Cells(x,1) <> "0" Or Cells(x,3) <> "" Or Cells(x,3) <> "0" Then Cells(x,11).EntireRow.Delete End If End If Next x But that code ignores the conditions except the first one, then also deletes the other row s with incomplete details.
I'm kind of stuck with this, since I also have to create another one where I do the reverse, keep the complete details, and delete the incomplete ones.
https://stackoverflow.com/questions/67052187/delete-rows-if-cell-does-not-equal-to-zero-or-blank April 12, 2021 at 11:09AM
没有评论:
发表评论