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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,216,107
Messages
6,128,869
Members
449,475
Latest member
Parik11

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