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
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