Creating a Hide Button to Hide Rows with Zero in particular cell

Koshi

New Member
Joined
Nov 1, 2019
Messages
1
In my previous company, we had a full-time Excel Guru who would do crazy coding to simplify our analysis job and she created an analysis sheet which had prepopulated items which may or may not be useful for a particular project. The ones which are NOT useful will remain zero, and can be hidden by pressing Hide Button.
For ex: If any cell in Column E is Zero, there can be a button to Hide the whole row which is E4 row and E9 row. If i remember right, it was a combination of Conditional Formatting and VBA.
[TABLE="width: 489"]
<tbody>[TR]
[TD]A1[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Item[/TD]
[TD]Cost[/TD]
[TD]Qty[/TD]
[TD]Total[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Product X[/TD]
[TD] $5.00[/TD]
[TD]5[/TD]
[TD] $25.00[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Product Y[/TD]
[TD] $ -[/TD]
[TD]0[/TD]
[TD] $-[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Product Z[/TD]
[TD] $4.00[/TD]
[TD]1[/TD]
[TD] $4.00[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Subtotal[/TD]
[TD][/TD]
[TD][/TD]
[TD] $29.00[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Product A[/TD]
[TD] $2.00[/TD]
[TD]4[/TD]
[TD] $8.00[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Product B[/TD]
[TD] $1.00[/TD]
[TD]6[/TD]
[TD] $6.00[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Product A[/TD]
[TD] $ -[/TD]
[TD]0[/TD]
[TD] $-[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Subtotal[/TD]
[TD][/TD]
[TD][/TD]
[TD] $14.00[/TD]
[/TR]
</tbody>[/TABLE]

Any help or assistance is appreciated. :)
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
.
Code:
Option Explicit


Sub UnHide()
Dim i As Integer


Application.ScreenUpdating = False


For i = 2 To 1000
    If Cells(i, 5).Value >= 0 Then
        Cells(i, 5).EntireRow.Hidden = False
    End If
Next i


Application.ScreenUpdating = True


End Sub


Sub hiderows()
Dim srchStr
Dim iLastRow As Integer
Dim i As Integer
Dim c As Range


    With Worksheets("Sheet1")
        .Activate
        ' // Need in case sheet is protected
        On Error Resume Next
        .Cells.EntireRow.Hidden = False
        ' // Finds last used row
        iLastRow = ActiveSheet.UsedRange.Rows.Count
        Set srchStr = Application.Selection
        srchStr = "$-"  'Application.InputBox("Find Text", "")
        ' // Loop through used rows
        For i = 2 To iLastRow
            For Each c In .Range("E" & i)
                If InStr(c.Value, srchStr) Then
                    GoTo found
                End If
            Next c
            Rows(i).Hidden = True
found:
        Next i
    End With
End Sub

Download workbook : https://www.amazon.com/clouddrive/share/zbGvROzAKIbNbnYXZ9n8W5yGejFLgXie9zS6llHrCI4
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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