Hide Cells with Zero values

pambard

New Member
Joined
Dec 21, 2005
Messages
8
Is there any way to hide cells with Zero values? I have around 2000 rows and need to hide Zero values before printing.

Thanks, Pravin
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try this:

Sub Hide()

Const LastRow As Integer = 2000
Const DataCol as Integer = (the test column)
Dim Row As Integer

For Row = 1 To LastRow
If CInt(Cells(Row, DataCol)) = 0 Then
ActiveSheet.Rows(Row).Hidden = True
Else
ActiveSheet.Rows(Row).Hidden = False
End If
Next Row

End Sub

Put your own values in the constants. (You could just put values in the code. I've got in the habit of using constants because with more complex code, it's a lot easier to figure out what's going on a year later!)

Using CInt means it will still work if there are errors in the column, otherwise it falls over
 
Upvote 0
How about something like this:

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveWindow.DisplayZeros = False
End Sub

Code:
Sub TurnOnZeros()
ActiveWindow.DisplayZeros = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,718
Members
448,986
Latest member
andreguerra

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