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.
A1BCDE
2ItemCostQtyTotal
3Product X $5.005 $25.00
4Product Y $ -0 $-
5Product Z $4.001 $4.00
6Subtotal $29.00
7Product A $2.004 $8.00
8Product B $1.006 $6.00
9Product A $ -0 $-
10Subtotal $14.00

<tbody>
</tbody>

Any help or assistance is appreciated. :)
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
.
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,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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