If you wanted, you could have a foo2:
Sub foo2(r As Range)
Dim rows As Long, i As Long
rows = r.rows.Count
For i = rows To 1 Step -1
If Evaluate("Sumproduct(len(" & r.rows(i).Address & "))") = 0 Then r.rows(i).Delete xlShiftUp
Next
End Sub
then if you have a selection of cells, even a noncontiguous selection of cells such as A6:D12,A15:D19,A23:D34, you could call it like this:
Sub test()
foo2 ActiveSheet.Range("A6:F13")
End Sub
or
Sub blah()
Dim are As Range
For Each are In Range("A6:D12,A15:D19,A23:D34").Areas
foo2 are
Next are
End Sub
or:
Sub blah()
Dim are As Range
For Each are In Selection.Areas
foo2 are
Next are
End Sub
Second thoughts post posting, you might have to be VERY CAREFUL with multiselections; you should select from the bottom up: lowest range on the sheet first, then the next one up , etc. Likewise with the likes of
Range("A6:D12,A15:D19,A23:D34").Areas
it should be
Range("A23:D34,A15:D19,A6:D12").Areas
Third thought post posting, scrub that last; Excel seems to handle it OK, but be aware that if the noncontiguous ranges have columns which overlap, but not totally, then things could get messy. If that's the case then come back, there is a more robust way.