Formatting a filter command.

USAMax

Well-known Member
Joined
May 31, 2006
Messages
849
Office Version
  1. 365
Platform
  1. Windows
I have revised the original command several ways and I still cannot get it to work.

ORIGINAL COMMAND
ActiveSheet.Range("$A$89:$K$140").AutoFilter Field:=6, Criteria1:=Array("2", "3", "4"), Operator:=xlFilterValues

MY COMMAND
ActiveSheet.Range("$A$" & Str(intFirstCompRow) & ":$K$" & Str(intLastCompRow)).AutoFilter Field:=6, Criteria1:=Array(Str(Cells(intFirstCompRow + 1, 5) - 1), Str(Cells(intFirstCompRow + 1, 5)), Str(Cells(intFirstCompRow + 1, 5) + 1)), Operator:=xlFilterValues

intFirstCompRow = 89
intLastCompRow = 140
Cells(intFirstCompRow + 1, 5) = 3 NOTE: This cell is F91 and formatted as a general format.

This should filter to values from 2 to 4.

Thank you everyone!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
UPDATE...

After I set the AutoFilter, I defined the range that I am using but it still does not work.

Set rngComp = Selection
ActiveSheet.rngComp.AutoFilter Field:=6, Criteria1:=Array(Str(Cells(intFirstCompRow + 1, 5) - 1), Str(Cells(intFirstCompRow + 1, 5)), Str(Cells(intFirstCompRow + 1, 5) + 1)), Operator:=xlFilterValues

Any suggestions, please?
 
Upvote 0
UPDATE...

I found a working solution. The range did not work, also the Str( command added a space. So this is my solution.

ActiveSheet.Range("$A$" & strFirstCompRow & ":$K$" & strLastCompRow).AutoFilter Field:=6, Criteria1:=Array(Str(Cells(intFirstCompRow + 1, 6) - 1), Str(Cells(intFirstCompRow + 1, 6)), Str(Cells(intFirstCompRow + 1, 6) + 1)), Operator:=xlFilterValues

Any help to simplify this would be appreciated.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,587
Messages
6,179,735
Members
452,939
Latest member
WCrawford

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