Hide Unhide based on cell values.

davidp227

New Member
Joined
Dec 21, 2018
Messages
1
Hello,
1st time poster
Excel level NOOB

So I have a workbook and on page 1 of the workbook A22 through A40=A22 through A40 of page 2. A22 through A40 on both page 1 and 2 are formatted as general. The idea here is that I need the data on page 1 to reflect the data on page 2 however on page 2 I may only have text data in some of the rows between A22 and A40 so I am left with rows on page 1 with 0 in them "not sure why its putting a 0 there when the formula in it is linking it to the data in that row on page 2. So I want to in VB hide the rows with a zero value by clicking a button. I have the button figured out and assigned the following macro that I found in a thread on here "thanks!"

Sub Test_Hide_0()
Application.ScreenUpdating = False
Dim i As Integer
Dim Lastrow As Long
With Sheets("Morning Report")
Lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Lastrow
If .Cells(i, 1).Value = "0" Then .Rows(i).Hidden = True
Next
End With
Application.ScreenUpdating = True
End Sub

I need page 1 to unhide hidden rows when updates are made to page 2 the data that is entered on page 2 will always be a text value not numerical. So when I hit the run macro button on page 1 it will unhide any cells that were previously hidden due to a 0 value that has changed to a text value.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I think this should do the trick for you:

Rich (BB code):
Sub Test_Hide_0()
Application.ScreenUpdating = False
Dim i As Integer
Dim Lastrow As Long
With Sheets("Morning Report")
Lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Lastrow
If .Cells(i, 1).Value = "0" Then 
.Rows(i).Hidden = True
else
.Rows(i).Hidden = False
end if
Next
End With
Application.ScreenUpdating = True
End Sub

Good luck.
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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