Just a beginner with VBA, trying to get this code to work in all sheets. Right now in only works in the active sheet. Ultimately it's supposed to delete all empty rows in all the worksheets.
Any Help is greatly appreciated
MZING81
Code:
Public Sub DeleteCompletelyBlankRows()
Dim as worksheet
For each WS in Worksheets
Dim R As Long
Dim C As Range
Dim N As Long
Dim Rng As Range
On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
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
N = N + 1
End If
Next R
EndMacro:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
MZING81