Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate a filter lookup to copy the results using a macro 1

Status
Not open for further replies.

rcbatlinux

Technical User
Mar 30, 2001
80
0
0
US
I am trying to automate a filter lookup and then copy the results using a macro. The problem I'm having is specifying the criteria. I want the criteria lookup be based on the value of a field. Here is what I have:

Range("B1").Select
Selection.Copy
Sheets("Team Data").Select
Range("L2").Select
ActiveSheet.Paste
Range("A1").Select
Application.CutCopyMode = False
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:=


If I make the Criteria1:= a literal it works fine. But I want it to look at the value of a cell. I tried entering in the cell address and the range command but neither worked. Any ideas?

Rick




 
Thanks for the reply. I dug a little deeper and realized I could just use the Advanced Filter option which allows me to specify a criteria from a cell address. thanks.

Rick
 
rcbatlinux - I need to use the advancedfilter in VBA - can you provide the code - I tried using a it but can't get the criteria piece to function correctly.
 
JCRMet,

I created the code by making a separate macro and copying and pasting the code into the macro I was going to run. I used the advanced filter option. Below is the code:

Range("A1:J7").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Sheets("Sheet1").Range("A1:A2"), Unique:=False

Hope this helps.

Regards,

rcbatlinux
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top