Connecting table filter to cell value

floragray

New Member
Joined
Jul 22, 2013
Messages
19
Hi All

I have a table and I need it to filter on the basis of a value entered in a different cell -
but i want it to show all rows greater than and equal to that specific value.



Sub Testmacro()
filtercriteria = Range("H3").Value

Sheets("Report 1").ListObjects("Table1").Range.AutoFilter _
Field:=4, Criteria1:=">=filtercriteria"

End Sub



Can anyone help me fix this?

Thanksss a ton!!!!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Code:
Sub Testmacro()   dim FilterCriteria as variant
   filtercriteria = Range("H3").Value


   Sheets("Report 1").ListObjects("Table1").Range.AutoFilter _
        Field:=4, Criteria1:=">=" & filtercriteria


End Sub

You had the word filtercriteria in your criteria1 - it would read ">=filtercriteria"
but you want the value of filtercriteria, so stop the string and append the value:
if Filtercriteria is 4 then now it will read ">=4"

I also suggest that you start each module with
Code:
Option Explicit
(you can do that automatically in the tools/options/Require Variable Declaration)
That will force you to dim each variable, and prevent errors. See also my guide, link below.
 
Upvote 0

Forum statistics

Threads
1,215,545
Messages
6,125,448
Members
449,227
Latest member
Gina V

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