Autofilter out Zeros

kylehawkins79

New Member
Joined
May 31, 2019
Messages
7
Im trying to auto filter out zeros on a sheet when a cell is updated. Is there a simple VBA that can do this?


Also If a cell is blank, I want to hide certain rows on a separate sheet. is there another for this?

Thank you
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Im trying to auto filter out zeros on a sheet when a cell is updated. Is there a simple VBA that can do this?


Also If a cell is blank, I want to hide certain rows on a separate sheet. is there another for this?

Thank you

You can use something like this
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=2, Criteria1:="<>" & 0, Operator:=xlFilterValues
Except make sure you use your table name instead of table2, and your field instead of field 2
 
Upvote 0
You can use something like this
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=2, Criteria1:="<>" & 0, Operator:=xlFilterValues
Except make sure you use your table name instead of table2, and your field instead of field 2

probably something like this is good just put the right sheet name and where it says A1 you can put the starting location of the rows you want to filter
Code:
Sub TurnOFFAutoFilter()


      If Worksheets("Sheet3").Range("A1").AutoFilter Then
                Worksheets("Sheet3").Range("A1").AutoFilter
      End If


      Worksheets("Sheet3").Range("A1").AutoFilter Field:=2, Criteria1:="<>0", Operator:=xlFilterValues


End Sub

The first part will check if there is a filter applied and remove it if needed, and then it filters out the 0s and the blanks to column2
 
Upvote 0
Also If a cell is blank, I want to hide certain rows on a separate sheet. is there another for this?

Thank you

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("B4").Value = "" Then
        Worksheets("Sheet2").Rows("2").EntireRow.Hidden = True
    Else
        Worksheets("Sheet2").Rows("2").EntireRow.Hidden = False
    End If
End Sub

This will work if you paste it into the worksheet where want to check for the blank value
go to that worksheet and right click the page name, select view code, and paste that code in

For example, paste this into the code on sheet1 and delete the contents of cell b4 then go to sheet 2 and check if row 2 is hidden. And you can change the cell ranges and row details as needed
 
Last edited:
Upvote 0
Im a novice at this so forgive me. If I need a single column (AD5) to auto update on Sheet A2 Checklist to not include zeros would I use the same VBA? I tried that one and it didnt work. Thanks again
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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