Code Visual Basic

Solved/Closed
mcculloch1dj Posts 2 Registration date Tuesday March 24, 2015 Status Member Last seen March 26, 2015 - Mar 25, 2015 at 07:26 PM
mcculloch1dj Posts 2 Registration date Tuesday March 24, 2015 Status Member Last seen March 26, 2015 - Mar 26, 2015 at 06:09 PM
Hello,

I've been unable to copy data from one sheet to another, based on selecting multiple criteria.

I've been able to use the string below to copy rows to sheet 2 by selecting value ("5064") in Column G, sheet 1. I need to select more than one value ("5066, 5067") is also required, this also needs to copied over to sheet 2.

Thank you in advance for your answers.
Regards David ...

Application.ScreenUpdating = False
With Worksheets("Sheet1")
.Columns("G").AutoFilter field:=1, Criteria1:="5064"
.UsedRange.SpecialCells(xlCellTypeVisible).Copy _
Destination:=Worksheets("Sheet2").Range("A1")
End With
With Worksheets("Sheet2")
.Columns("G").Cut
.Columns("A").Insert
.Select
End With
Worksheets("Sheet1").AutoFilterMode = False
Application.ScreenUpdating = True
Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Mar 26, 2015 at 12:21 PM
Hi David,

Try replacing the following line:
.Columns("G").AutoFilter field:=1, Criteria1:="5064"

with this one:
.Columns("G").AutoFilter field:=1, Criteria1:=Array("5064", "5066", "5067"), Operator:=xlFilterValues


Best regards,
Trowa
Monday, Tuesday and Thursday are usually the days I'll respond. Bear this in mind when awaiting a reply.
0
mcculloch1dj Posts 2 Registration date Tuesday March 24, 2015 Status Member Last seen March 26, 2015
Mar 26, 2015 at 06:09 PM
TrowaD

Your solution worked perfectly, thanks heaps really appreciated your prompt answer

Regards David ....
0