View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default Hide and printout area conditions

I'm confused. What exactly has to be true in order to hide a row?

--
Jim Rech
Excel MVP
"Jonsson " wrote in message
...
| Hi all,
|
| I´m trying to "clean" the worksheet from unused rows before printing,
| and then get a print out that only shows whats necessary. The "cleaned"
| area is different every time, depending wether there are numbers in
| them or not. I´m using the code below, (thanks NOSPAM), but I get a
| very long "answertime" from this code. Is there anyway to modify it to
| work from D5:D206? I think it would go faster if the area is specified
| to D5:D206, than to the bottom row, or.......?
|
| I assume I have to modify it more than just change the area B:B,
| becouse that doesnt work.
|
| Thanks in advance!
|
| //Thomas
|
|
| Sub CleanUporg()
| 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/
|