Consulting

Results 1 to 2 of 2

Thread: Delete row when Cells D,E,F are empty.

  1. #1
    VBAX Newbie
    Joined
    Nov 2021
    Posts
    5
    Location

    Delete row when Cells D,E,F are empty.

    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

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,635
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •