Paste into autofilter Macro

  • Thread starter Thread starter Randy
  • Start date Start date
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
 
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
 
Back
Top