Trying to delete rows with no values (but contain formulas, conditional formatting) from the bottom up in a three page worksheet prior to printing. During execution, after row is found with data, exit sub.
ok, here's what I got so far...
The code below doesn't work probably because each blank row in my worksheet contains formulas. The CountA function did not see these rows as blank (I think), so therefore didn't delete them. Can I code so that the CountA function evaluates rows for VALUES only? If no values, then delete. See code below.
Thanks for your help.
Dim R As Long
Dim C As Range
Dim N As Long
Dim Rng As Range
'On Error GoTo EndMacro
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
N = 0
For R = Rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(Rng.Rows(R).EntireRow) = 0 Then
Rng.Rows(R).EntireRow.Delete
'Rows(Rng.Row).Hidden = True 'I woulk like to just hide them
N = N + 1
Else
Exit For
End If
Next R
ok, here's what I got so far...
The code below doesn't work probably because each blank row in my worksheet contains formulas. The CountA function did not see these rows as blank (I think), so therefore didn't delete them. Can I code so that the CountA function evaluates rows for VALUES only? If no values, then delete. See code below.
Thanks for your help.
Dim R As Long
Dim C As Range
Dim N As Long
Dim Rng As Range
'On Error GoTo EndMacro
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
N = 0
For R = Rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(Rng.Rows(R).EntireRow) = 0 Then
Rng.Rows(R).EntireRow.Delete
'Rows(Rng.Row).Hidden = True 'I woulk like to just hide them
N = N + 1
Else
Exit For
End If
Next R