Hide/unhide rows based on Column A (0/"")?

DarkJester89

Board Regular
Joined
Nov 5, 2017
Messages
109
Office Version
  1. 2016
Platform
  1. Windows
I found this code, and I put it in the worksheet code, saved and exited and it doesn't do anything on open. Thank you for your time.

VBA Code:
Private Sub Worksheet_Calculate()
Dim c As Range
Application.ScreenUpdating = False
For Each c In Me.Range("A1:A80")
    If c.Value = 0 Or c.Value = "" Then
        c.EntireRow.Hidden = True
    Else
        c.EntireRow.Hidden = False
    End If
Next c
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
That code fires when the worksheet calculates, not necessarily when the workbook is first opened or the worksheet is activated. What exactly are you wanting to do?
 
Upvote 0
I believe Worksheet_Calculate requires the sheet to recalculate. Not sure if that happens on Open...

These should be the triggers i'd assume


You could try Workbook Open and select the sheet perhaps

VBA Code:
Private Sub Workbook_Open()
 
Upvote 0
Just wondering, would you get the same result by using the Filter then dis-select the (blanks) & 0 values?
 
Upvote 0
Ok, well that is an event triggering it now. On button push use:

VBA Code:
Sub dostuff()
Dim c As Range
Application.ScreenUpdating = False
For Each c In Me.Range("A1:A80")
    If c.Value = 0 Or c.Value = "" Then
        c.EntireRow.Hidden = True
    Else
        c.EntireRow.Hidden = False
    End If
Next c
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

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