Paste into autofilter Macro

R

Randy

Hi everyone,
I need to build a macro that will copy the numbers from a
cell on one worksheet and paste them into an auto filter
on another worksheet. The problem I'm having is when
recording the macro the auto filter ends up with the same
data from the cell I built it from. Heres the code:

Keyboard Shortcut: Ctrl+w
'
Selection.Copy
Windows("BID_MSTR_12_1_03.xls").Activate
Selection.AutoFilter Field:=4, Criteria1:="1212",
Operator:=xlAnd
End Sub

Is there an statement that I can use that will enter what
was copied in "Selection.Copy" in the Criteria1: field?

Thanks

Randy
 
D

Debra Dalgleish

You can use code similar to the following:

str = Selection.Value
Windows("BID_MSTR_12_1_03.xls").Activate
Selection.AutoFilter Field:=4, _
Criteria1:=str, Operator:=xlAnd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top