How to print only rows with non zero values

swhitesides

New Member
Joined
Apr 17, 2009
Messages
16
:confused:I have a spreadsheet that is setup as a master template to accommodate 105 rows of data input. How can I make it display and print only the rows that non zero values have been entered. The final print needs to contain rows A1:A12 and A118:A129 along with A13:A117 containing non zero values only.

Data input is frequently changing so hiding the cells is not an acceptable option.

I was thinking a type of macro would solve this issue but all the ones I have tried are not working correctly.
 
Try:

Code:
ActiveSheet.PrintPreview

Yes this works, however I want to see my results on screen and choose to print later. Thats why I chose code ActiveSheet.Display, which works, its just that this code causes a run time error and I dont know how to make that go away.
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
There doesn't appear to be a

Code:
ActiveSheet.Display
option, that's why you're getting the error.

Try this:

Code:
Sub HideRowsFromBottom()
   Dim i As Long, LastRow As Long
   Application.ScreenUpdating = False
   StartRow = 13
   LastRow = 117
   Rows(StartRow & ":" & LastRow).EntireRow.Hidden = False
   'begin loop to check each row
   For i = LastRow To StartRow Step -1
       'if cell=0, hide row
       If Cells(i, "D") = 0 and Cells(i, "E") = 0 and Cells(i, "F") = 0 and Cells(i, "G") = 0 Then Rows(i).Hidden = True
   Next i
   Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top