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(quot;Sheet1quot;)
For rw = 1 To 30
If Application.WorksheetFunction.CountA( _
.Cells(rw, 1).Range(quot;A1:G1quot;)) = 0 Then _
.Rows(rw).Hidden = True
Next rw
.PrintPreview
.Range(quot;A1:A30quot;).EntireRow.Hidden = False
End With
Application.ScreenUpdating = True
End Sub--
DHallam
------------------------------------------------------------------------
DHallam's Profile: www.excelforum.com/member.php...oamp;userid=25253
View this thread: www.excelforum.com/showthread...hreadid=544050Hi
You could try changing the test for the blank lines to
If Application.WorksheetFunction.CountBlank( _
Cells(rw, 1).Range(quot;A1:G1quot;)) = 7 Then _
Rows(rw).Hidden = True--
Regards
Roger Govierquot;DHallamquot; gt; wrote
in message news
gt;
gt; Hi all,
gt;
gt; I have this code that works really well for hiding rows when they do
gt; not have anything in. However the rows I need to hide all have
gt; formulas in as they pull data from other worksheets and therefore this
gt; code doesnt work. Does anyone know how i can get over this?
gt;
gt; The code i currently have is this:
gt;
gt; Sub Hide_Print_Unhide()
gt; Dim rw As Long
gt; Application.ScreenUpdating = False
gt;
gt; With Sheets(quot;Sheet1quot;)
gt; For rw = 1 To 30
gt; If Application.WorksheetFunction.CountA( _
gt; Cells(rw, 1).Range(quot;A1:G1quot;)) = 0 Then _
gt; Rows(rw).Hidden = True
gt; Next rw
gt; PrintPreview
gt; Range(quot;A1:A30quot;).EntireRow.Hidden = False
gt; End With
gt;
gt; Application.ScreenUpdating = True
gt; End Sub
gt;
gt;
gt; --
gt; DHallam
gt; ------------------------------------------------------------------------
gt; DHallam's Profile:
gt; www.excelforum.com/member.php...oamp;userid=25253
gt; View this thread:
gt; www.excelforum.com/showthread...hreadid=544050
gt;
- Jul 25 Fri 2008 20:45
Hiding rows when printing
close
全站熱搜
留言列表
發表留言
留言列表

