Deleting Rows Based on Column Critieria

  • Thread starter Thread starter blackmanofsteel40
  • Start date Start date
B

blackmanofsteel40

Basically, I'm trying to delete the entire row in my worksheet if
Columns F-P are all blank. I have this macro written so far, but I'm
can't seem to decipher what I'm missing to have it work. Thanks in
advance for helping with my novice programming.

Sub Gift()

With .Cells(Lrow, "F")


If Application.CountA(.Range(.Cells(Lrow,
"F"), .Cells(Lrow, "P"))) = 0 Then .Rows(Lrow).Delete


End With
End Sub
 
Basically, I'm trying to delete the entire row in my worksheet if
Columns F-P are all blank. I have this macro written so far, but I'm
can't seem to decipher what I'm missing to have it work. Thanks in
advance for helping with my novice programming.

Sub Gift()

With .Cells(Lrow, "F")

If Application.CountA(.Range(.Cells(Lrow,
"F"), .Cells(Lrow, "P"))) = 0 Then .Rows(Lrow).Delete

End With
End Sub



Sorry is the full code that I'm having problems with:

Sub Loop_Example()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow =
ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row

For Lrow = Lastrow To Firstrow Step -1

If Application.CountA(.Range(.Cells(Lrow, "F"), .Cells(Lrow,
"P"))) = 0 Then .Rows(Lrow).Delete


Next Lrow

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub
 
Sub Gift()
Dim r as Range, lrow as Long, i as Long
set r = ActiveSheet.UsedRange
lrow = r.rows(r.rows.count).row

for i = lrow to 1 step -1
With ActiveSheet


If Application.CountA(.Range(.Cells(i,"F"), _
.Cells(i, "P"))) = 0 Then
.Rows(i).Delete
end if

End With
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top