Checkbox to hide/unhide if zero

DaveAtlanta

Board Regular
Joined
Nov 9, 2005
Messages
100
I am trying to set a check box to hide rows that have a zero value formula. I was able to piece together this macro to hide, but can't seem to figure out how to unhide when the check box is unchecked.

If CheckBox15 = False Then
Dim i As Integer
With Range("r6")
For i = 1 To 54
If .Offset(i, 0) <> 0 Then
.Offset(i, 0).EntireRow.Hidden = False
Else
.Offset(i, 0).EntireRow.Hidden = True
End If
Next
End With
End If

I would appreciate any suggestions and advise.
Dave
in Atlanta
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hello Dave,

What about something like:

Code:
If CheckBox15 = False Then                       ' if Check Box is unchecked then unhide everything
      Range("R6:R60").EntireRow.Hidden = False
    Else                                             ' else hide zeroes
      Range("R6:R60").Replace "0", "", xlWhole                 'change 0's to blanks
      Range("R6:R60").SpecialCells(xlCellTypeBlanks).Select    'select blanks
      Selection.EntireRow.Hidden = True                        'hide blanks
      Selection.Value = 0                                      'put 0's back
    End If
HTH,
 
Upvote 0
Thanks, but that's not quite what I need.

My totals column is all formulas which I don't want to replace. I was hiding the rows manually using the Ctrl-9, then unhiding manually. But now that it has grown I would like a macro using a check box to look at the totals and all the zeros hide, but still being able to uncheck the checkbox to re-display the rows that had a zero value.

thanks
Dave
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,520
Members
449,088
Latest member
RandomExceller01

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