How can i auto filter on 2 columns with Multiple criteria and then copy columns to different sheet

simmybehl

New Member
Joined
Aug 23, 2016
Messages
4
Hi Team,

I am using below macro to auto filter on col D and Col F on worksheet "confirms" with below criterias and then trying to copy col P and Col S filtered data to another worksheet names "Non=Cash Trades".

the below code is autofiltering only col D with "N" and Col F with "COD" not "F/D" and copy function is not working at all. Please help.

Sub Copy()
Dim i As Long, LR As Long
Dim sht, sht1 As Worksheet


Set sht = ActiveWorkbook.Worksheets("confirms")
Set sht1 = ActiveWorkbook.Worksheets("NON-CASH Trades")


sht.Range("A:S").AutoFilter Field:=4, Criteria1:=Array("N")
sht.Range("A:S").AutoFilter Field:=6, Criteria1:=Array("F/D", "COD")
sht.Range("P2:P5000").Copy
sht1.Range("A4:A5000").PasteSpecial xlPasteValues
sht.Range("S2:S5000").Copy
sht1.Range("C4:C5000").PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi & welcome to MrExcel
Try
Code:
sht.Range("A:S").AutoFilter 4, "N"
sht.Range("A:S").AutoFilter 6, Array("F/D", "COD"), xlFilterValues
For the filter
 
Upvote 0
Hey, thanks so much!!

yes the autofilter does work now exactly the way i want.

Request you to please shed some light on the copy code as well, why isnt it working..
 
Upvote 0
Please define "Isn't working"
 
Upvote 0
i mean the below, doesn't work, like i need macro to copy cells of col P & col S after placing the above auto filter to the another worksheet starting from col A row 4 and col C starting from row 4 respectively

sht.Range("P2:P5000").Copy
sht1.Range("A4:A5000").PasteSpecial xlPasteValues
sht.Range("S2:S5000").Copy
sht1.Range("C4:C5000").PasteSpecial xlPasteValues
Application.CutCopyMode = False
 
Upvote 0
In what way "Doesn't it work"?
Do you get error messages?
Does it copy everything?
Does it copy nothing?
Or what?
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,106
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top