Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default Hide rows that are empty without autofilter between data

Hey,

I need a VB script that will hide rows in an invoice that are not full of
data.

If I only have 1 item, but my invoice has 90 lines of possible data, I'd
like for it to hide the 89 remaining rows before the subtotal so it can be
neat and fit nicely on 1 page. If you can help, thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Hide rows that are empty without autofilter between data

Hi Tony

This example will loop through row 1:30 in "Sheet1"
If every cell in column A:G is empty it will hide that row.
After the loop it print the sheet and then unhide the rows.

You can also use this with non contiguous ranges Range("B1,D1:G1")
If the cells in column B and D:G are empty it will hide that row.


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
.PrintOut ' for testing use .PrintPreview
.Range("A1:A30").EntireRow.Hidden = False
End With

Application.ScreenUpdating = True
End Sub


--
Regards Ron De Bruin
http://www.rondebruin.nl



"Tony" wrote in message ...
Hey,

I need a VB script that will hide rows in an invoice that are not full of
data.

If I only have 1 item, but my invoice has 90 lines of possible data, I'd
like for it to hide the 89 remaining rows before the subtotal so it can be
neat and fit nicely on 1 page. If you can help, thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default Hide rows that are empty without autofilter between data

Thank you very much this was helpful and worked

"Ron de Bruin" wrote:

Hi Tony

This example will loop through row 1:30 in "Sheet1"
If every cell in column A:G is empty it will hide that row.
After the loop it print the sheet and then unhide the rows.

You can also use this with non contiguous ranges Range("B1,D1:G1")
If the cells in column B and D:G are empty it will hide that row.


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
.PrintOut ' for testing use .PrintPreview
.Range("A1:A30").EntireRow.Hidden = False
End With

Application.ScreenUpdating = True
End Sub


--
Regards Ron De Bruin
http://www.rondebruin.nl



"Tony" wrote in message ...
Hey,

I need a VB script that will hide rows in an invoice that are not full of
data.

If I only have 1 item, but my invoice has 90 lines of possible data, I'd
like for it to hide the 89 remaining rows before the subtotal so it can be
neat and fit nicely on 1 page. If you can help, thanks in advance.




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
Hide Rows based on value, but not using autofilter Richhall[_2_] Excel Worksheet Functions 2 November 11th 09 02:31 PM
hide empty rows on open Joshy Excel Discussion (Misc queries) 1 August 28th 09 01:52 PM
faster way to hide rows w/o using autofilter? [email protected] Excel Programming 3 May 25th 06 05:39 PM
Hide Empty Rows When Printing Bob Excel Worksheet Functions 5 August 20th 05 12:57 PM
Format to hide empty rows tamato43 Excel Discussion (Misc queries) 4 May 10th 05 10:16 PM


All times are GMT +1. The time now is 07:46 AM.

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"