Avatar of Justin Smith
Justin Smith
Flag for United Kingdom of Great Britain and Northern Ireland asked on

problem with Autofilter macro

problem with Excel Autofilter macro. I have recorded a macro where I filter on row C and select from column 45 in a drop down filter the option ">1", then copy and paste the block of data tyanother tab. However, when I run macro, it selects all different fields (9M-1Y, 6-9M,) anyone any idea why?
Microsoft ExcelVisual Basic ClassicMicrosoft Office

Avatar of undefined
Last Comment
Justin Smith

8/22/2022 - Mon
Rob Henson

A copy of the file in question would be useful. Don't fully understand what you are describing; seem to have rows and columns mixed up.
Justin Smith

ASKER
hi Rob, I cannot send it due to company firewalls. it's just a block of data that goes from C3 to BZ200. i just need to filter on a certain Time period in column 45 and I am trying to select ">-1" which means less than 1 month. when I record it, it works but when I run the macro it select other time periods in the column "3-6 months", "9-12 months". why would this happen?
Justin Smith

ASKER
Sub WAL ()        

Sheets ("CD"). Select
Rows ("3:3"). Select
Activesheet.Range ("A3:bz200). AutoFilter:=45, Criteria1:="<1M"
Range ("Y3").  Select
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Rob Henson

Think you might need to double up on the double quotes to make a text string:
Criteria1:=""<1M""
Justin Smith

ASKER
I am getting an error message when I add the double quotations - "Expected End of Statement"
Justin Smith

ASKER
ok, I tried Activesheet.Range ("A3:BZ200). Autofilter Field:=45, Criteria1:="""<1M""". but it does not select any option
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Rob Henson

What are the exact text values in the column needing filter? I will put together a file with some duff data
SOLUTION
Rob Henson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Justin Smith

ASKER
Rob's knowledge of VB is superb