Problem with this code

  • Thread starter Thread starter Jonsson
  • Start date Start date
J

Jonsson

Hi,

I have found this code, posted by "NO SPAM".

Somehow I get an error at "If" after "step-1".
Whats wrong?
I think this code would help me to get what I need, but I cant get i
work like this.

Thanks in advance

//Thomas


Sub CleanUp()
Dim CurrentRow As Long
Dim UsedRows As Range
On Error GoTo Abort
Set UsedRows = ActiveSheet.UsedRange.Rows
For CurrentRow = UsedRows.Rows.Count To 1 Step -1
If
Application.WorksheetFunction.Sum(UsedRows.Rows(CurrentRow).Columns("B:B"))
= 0 Then
UsedRows.Rows(CurrentRow).EntireRow.Hidden = True
Else UsedRows.Rows(CurrentRow).EntireRow.Hidden =
False
End If
Next CurrentRow
' If only hiding for printing purposes, use the next two lines to prin
or
preview then restore the worksheet
'ActiveWindow.SelectedSheets.PrintPreview
'ActiveSheet.Rows.EntireRow.Hidden = False
Abort:
End Su
 
The 3 lines

If
Application.WorksheetFunction.Sum(UsedRows.Rows(CurrentRow).Columns("B:B"))
= 0 Then

should all be one line, but seem to have wrapped around in the NG

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top