How do I modify this VBA, to filter specific cell Values.

russelldt

Board Regular
Joined
Feb 27, 2021
Messages
158
Office Version
  1. 365
Platform
  1. MacOS
I have this VBA in place.

Sub BS()
With Sheets("PD List")
If .FilterMode = False Then
With .Range("f:i").EntireColumn
.Hidden = True
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=4, Criteria1:= _
"<>"
End With
Else
With .Range("f:i").EntireColumn
.Hidden = False
ActiveSheet.ListObjects("Table2").Range.AutoFilter
End With
End If
End With

End Sub

Field 4 contains numeric values, and a . (point or dot).

I want the VBA to exclude "0" and "." in the result.

Please can someone help me other,

Thanks
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
These are all the table commands
Entire Table = ActiveSheet.ListObjects("Table1").Range.Select
Table Header Row = ActiveSheet.ListObjects("Table1").HeaderRowRange.Select
Table Data = ActiveSheet.ListObjects("Table1").DataBodyRange.Select
Second Column = ActiveSheet.ListObjects("Table1").ListColumns(2).Range.Select
Third Column (Data Only) = ActiveSheet.ListObjects("Table1").ListColumns(3).DataBodyRange.Select
Select Row 3 of Table Data = ActiveSheet.ListObjects("Table1").ListRows(3).Range.Select
Select 3rd Heading = ActiveSheet.ListObjects("Table1").HeaderRowRange(3).Select
Select Data point in Row 4, Column 3 = ActiveSheet.ListObjects("Table1").DataBodyRange(4, 3).Select
Subtotals = ActiveSheet.ListObjects("Table1").TotalsRowRange.Select
 
Upvote 0
These are all the table commands
Entire Table = ActiveSheet.ListObjects("Table1").Range.Select
Table Header Row = ActiveSheet.ListObjects("Table1").HeaderRowRange.Select
Table Data = ActiveSheet.ListObjects("Table1").DataBodyRange.Select
Second Column = ActiveSheet.ListObjects("Table1").ListColumns(2).Range.Select
Third Column (Data Only) = ActiveSheet.ListObjects("Table1").ListColumns(3).DataBodyRange.Select
Select Row 3 of Table Data = ActiveSheet.ListObjects("Table1").ListRows(3).Range.Select
Select 3rd Heading = ActiveSheet.ListObjects("Table1").HeaderRowRange(3).Select
Select Data point in Row 4, Column 3 = ActiveSheet.ListObjects("Table1").DataBodyRange(4, 3).Select
Subtotals = ActiveSheet.ListObjects("Table1").TotalsRowRange.Select
Thanks for the response - apologies, with my limited knowledge of VBA I can't follow the logic.

I am also limited with the version of Excel that I am using (2019) which does not have the advanced data functions.
 
Upvote 0
How about
VBA Code:
Sub BS()
With Sheets("PD List")
   If .FilterMode = False Then
      .Range("f:i").EntireColumn.Hidden = True
      .ListObjects("Table2").Range.AutoFilter Field:=4, Criteria1:="<>0"
   Else
      .Range("f:i").EntireColumn.Hidden = False
      .ListObjects("Table2").Range.AutoFilter
   End If
End With

End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub BS()
With Sheets("PD List")
   If .FilterMode = False Then
      .Range("f:i").EntireColumn.Hidden = True
      .ListObjects("Table2").Range.AutoFilter Field:=4, Criteria1:="<>0"
   Else
      .Range("f:i").EntireColumn.Hidden = False
      .ListObjects("Table2").Range.AutoFilter
   End If
End With

End Sub
Magic, Once again, thanks Fluff.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,076
Messages
6,128,670
Members
449,463
Latest member
Jojomen56

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