PDA

View Full Version : [SOLVED:] Delete row when Cells D,E,F are empty.



Sinlink
11-20-2021, 06:55 AM
Hi all,
I found this Code on the Internet and it works great.
It erases all lines that have empty cells in B and C.

The only thing I would like to change is that it should erase the Line when the cells in D,E,F are empty.

I am too stupid to figure it out.



Sub Delete_Row_when_column_B_and_C_are_blank_for_that_row()


Dim i As Integer
Dim Lastrow As Integer


Lastrow = Range("A" & Rows.Count).End(xlUp).Row
MsgBox (Lastrow)
For i = Lastrow To 2 Step -1
If Trim(Range("B" & i).Value) = "" And Trim(Range("C" & i).Value) = "" Then
Range("B" & i).EntireRow.Select
Selection.Delete


End If


Next i


MsgBox "Done"


End Sub


Thanks for your help.
Tom

snb
11-20-2021, 08:39 AM
Sub M_snb()
for each it in sheet1.usedrange.columns(4)specialcells(4)
if it.resize(,3).specialcells(4).count =3 then it=1\0
next
sheet1.usedrange.columns(4).specialcells(2,16).entirerow.delete
End Sub