anwilson

New Member
Joined
Apr 17, 2019
Messages
13
Morning all.

I have a column on sheet 1 with different numbers in it (150, 300, 600, 900, 1500, 2500) ad would like to filter it based on the number given on sheet 2, cell B5 (I have the criteria listed on sheet 2 as well). I've tried manually writing the advanced filter macro, and when that didn't work I tried recording it which didn't work either.

Code:
pressure = sh2.Range("B5").Value

If pressure > 0 And pressure <= 150 Then
sh1.Columns("Y").AutoFilterMode = False

ElseIf pressure >150 And pressure <= 300 Then
sh1.Select
Range("Y3:Y600").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
sh2.Range("BA2:BA6"), Unique = False

End If

Any help is appreciated!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,215,523
Messages
6,125,317
Members
449,218
Latest member
Excel Master

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