VBA to copy values IF

  • Thread starter Thread starter Memphus01
  • Start date Start date
M

Memphus01

How can I create a statement that will select all rows on sheet 1 that have
Value "X" (text) in Column B and then paste into Sheet 2, A2?
 
Ron - thanks for your help --

it runs perfectly---but when I tried to step out on my own a bit and create
up to 8 criteria I am messing up somewhere---

in the line--

rng.AutoFilter Field:=1, Criteria1:="=Netherlands", Operator:=xlOr,
Criteria2:="=USA"

how would I add a third crtieria, etc? I tried the following:

rng.AutoFilter Field:=1, Criteria1:="=Netherlands", Operator:=xlOr,
Criteria2:="=USA", Operator:=xlOr, Criteria3:="=FRANCE" , Operator:=xlOr,
Criteria4:="=Germany"

but keep getting an error on the third Criteria---

Thanks
 
There is a Max of 2 when you use AutoFilter
You can use Advanced filter or use a helper column with

=OR(A2={"USA","USA2","USA3","USA4","USA5"})

Then use AutoFilter on that column
 

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

Back
Top