Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
DHallam
 
Posts: n/a
Default Hiding rows when printing


Hi all,

I have this code that works really well for hiding rows when they do
not have anything in. However the rows I need to hide all have
formulas in as they pull data from other worksheets and therefore this
code doesnt work. Does anyone know how i can get over this?

The code i currently have is this:

Sub Hide_Print_Unhide()
Dim rw As Long
Application.ScreenUpdating = False

With Sheets("Sheet1")
For rw = 1 To 30
If Application.WorksheetFunction.CountA( _
.Cells(rw, 1).Range("A1:G1")) = 0 Then _
.Rows(rw).Hidden = True
Next rw
.PrintPreview
.Range("A1:A30").EntireRow.Hidden = False
End With

Application.ScreenUpdating = True
End Sub


--
DHallam
------------------------------------------------------------------------
DHallam's Profile: http://www.excelforum.com/member.php...o&userid=25253
View this thread: http://www.excelforum.com/showthread...hreadid=544050

  #2   Report Post  
Posted to microsoft.public.excel.misc
Roger Govier
 
Posts: n/a
Default Hiding rows when printing

Hi

You could try changing the test for the blank lines to

If Application.WorksheetFunction.CountBlank( _
Cells(rw, 1).Range("A1:G1")) = 7 Then _
Rows(rw).Hidden = True


--
Regards

Roger Govier


"DHallam" wrote
in message ...

Hi all,

I have this code that works really well for hiding rows when they do
not have anything in. However the rows I need to hide all have
formulas in as they pull data from other worksheets and therefore this
code doesnt work. Does anyone know how i can get over this?

The code i currently have is this:

Sub Hide_Print_Unhide()
Dim rw As Long
Application.ScreenUpdating = False

With Sheets("Sheet1")
For rw = 1 To 30
If Application.WorksheetFunction.CountA( _
Cells(rw, 1).Range("A1:G1")) = 0 Then _
Rows(rw).Hidden = True
Next rw
PrintPreview
Range("A1:A30").EntireRow.Hidden = False
End With

Application.ScreenUpdating = True
End Sub


--
DHallam
------------------------------------------------------------------------
DHallam's Profile:
http://www.excelforum.com/member.php...o&userid=25253
View this thread:
http://www.excelforum.com/showthread...hreadid=544050



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
resetting last cell jagdish.eashwar Excel Discussion (Misc queries) 11 March 31st 06 02:06 AM
Removing Rows for Printing Frick Excel Worksheet Functions 20 March 10th 06 10:53 PM
Printing only Rows with Visible Data Storm Excel Discussion (Misc queries) 7 December 8th 05 09:19 PM
Hiding of rows and columns srinivasan Excel Discussion (Misc queries) 1 July 21st 05 08:59 AM
Printing only certain rows Jon W Excel Discussion (Misc queries) 1 February 9th 05 01:15 AM


All times are GMT +1. The time now is 10:13 PM.

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

About Us

"It's about Microsoft Excel"