Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with this code

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(Cu rrentRow).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

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Problem with this code

The 3 lines

If
Application.WorksheetFunction.Sum(UsedRows.Rows(Cu rrentRow).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)

"Jonsson " wrote in message
...
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 it
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(Cu rrentRow).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 print
or
preview then restore the worksheet
'ActiveWindow.SelectedSheets.PrintPreview
'ActiveSheet.Rows.EntireRow.Hidden = False
Abort:
End Sub


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with this code

Hi Bob,

Thanks, you helped me a lot!

//Thoma

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code problem puiuluipui Excel Discussion (Misc queries) 3 July 3rd 09 07:27 PM
Alt Code Problem aftamath77 Excel Discussion (Misc queries) 2 February 10th 09 11:42 PM
XLS to CSV Code Problem carl Excel Worksheet Functions 0 March 28th 07 01:21 AM
Code Problem Todd Huttenstine Excel Programming 3 April 16th 04 09:25 PM
Code problem Rick[_11_] Excel Programming 1 August 8th 03 04:25 AM


All times are GMT +1. The time now is 11:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"