Macro for auto filter

manojparag

New Member
Joined
Oct 3, 2015
Messages
5
Hello Everyone,

I am writing a marco which has some data in sheet1 and a column in sheet2. I wanted that marco to work as


go to sheet2 pick the value(which is String) ---- then go to sheet1 do autofilter ----- search the string value which has taken from sheet2 ----- and then copy to sheet3.

This should repted till the sheet2 column get blank.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
so you can use macro recorder to build you autofilter for sheet1

do that an post it here in code tags

then you need to tell what column you are looking at for data on sheet 2 and how that is determined

copying from sheet 1 to sheet 3 can then be done,

what you are doing is planting seeds, but we have no idea if you are growing apples or coffee beans
 
Upvote 0
so you can use macro recorder to build you autofilter for sheet1

do that an post it here in code tags

then you need to tell what column you are looking at for data on sheet 2 and how that is determined

copying from sheet 1 to sheet 3 can then be done,

what you are doing is planting seeds, but we have no idea if you are growing apples or coffee beans


Yes I can do while recoding the macro and so I did. But I want be done with using do while or other vba funtion used.
 
Upvote 0
for example: ActiveSheet.Range("$A$1:$B$14").AutoFilter Field:=2,Criteria1:="=*Lion*" _Operator:=xlAnd

then again the second piece of code will be same with different criteria..
like..
ActiveSheet.Range("$A$1:$B$14").AutoFilter Field:=2,Criteria1:="=*Tiger*" _Operator:=xlAnd
and so on ActiveSheet.Range("$A$1:$B$14").AutoFilter Field:=2,Criteria1:="=*Panther*" _Operator:=xlAnd


I wanted rather taking or recoding macro and doing the same thing again and again. Can we run a loop in side a criteria which will take automatically take lion then tiger then Panther an so on...
 
Upvote 0
see thats relasesed a tiny bit of Info

Lion
Tiger
Panther

now I can see that Panther Alphabetically comes after Lion and Before Tiger, hence why I asked how you determine the order
 
Upvote 0
Yes see
Sheet 1:


Sheet 2:
 
Upvote 0
best will in the world I can't view your desktop remotely
 
Upvote 0

Forum statistics

Threads
1,221,813
Messages
6,162,117
Members
451,743
Latest member
matt3388

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