Hi i use the following code to delete rows if cells in columns F and G are empty,
Could someone adjust it so it would delete rows if cells in column F G and H are empty ?
Could someone adjust it so it would delete rows if cells in column F G and H are empty ?
VBA Code:
Sub DeleteRows1()
' Defines variables
Dim x As Long, LastRow As Long, cRange As Range
' Defines LastRow as the last row of data based on column D
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
' Sets the check range as D1 to the last row of D
Set cRange = Range("h15:g" & LastRow)
' For each cell in the check range, working from the bottom upwards
For x = cRange.Cells.Count To 1 Step -1
With cRange.Cells(x)
' If column A, B and C of the current row are all empty then...
If Application.WorksheetFunction.CountIf(Range("f" & .Row, "g" & .Row), "") = 2 Then
' Delete that row
.EntireRow.Delete
End If
End With
' Check next cell in check range, moving from the bottom upwards
Next x
' Display optional message to confirm the task is finished
MsgBox "Complete"
End Sub