thedeadzeds
Active Member
- Joined
- Aug 16, 2011
- Messages
- 451
- Office Version
- 365
- Platform
- Windows
Guys,
Is there a way to adapt the code below. It currently does the following but I would like to adapt to do as per the below steps. The final data will be a table not a range. Not sure if that makes a difference
Currently the code does the following ( code below)
filters by New call in field 10
Filters by the criteria in filed 13
Filters by person in field 16
Filters 50 records for that person
Copy and Paste to sheet 2
New adapted code would be as follows:
Current code:
Is there a way to adapt the code below. It currently does the following but I would like to adapt to do as per the below steps. The final data will be a table not a range. Not sure if that makes a difference
Currently the code does the following ( code below)
filters by New call in field 10
Filters by the criteria in filed 13
Filters by person in field 16
Filters 50 records for that person
Copy and Paste to sheet 2
New adapted code would be as follows:
- Filter by new call (or the value in cell A4 sheet1)
- Filter by MOT, Service, Service & MOT
- Filter by every person (field 16)
- Select the first 50 records for that person ( can this 50 be based on a number in cell A3 sheet1 so I can chase the volume if needed)
- Paste to sheet 2
- Then repeat for the next person in field 16 and paste to the bottom of the existing data in sheet 2 and so on.
- Also, Is there a way to over come if there is not 50 or the volume in cell A3 sheet1 then just copy what is there
Current code:
Code:
Sub Macro2()
'Filter New Call
Sheets("Sheet1").Select
ActiveSheet.Range("$A$1:$P$1315").AutoFilter Field:=10, Criteria1:= _
"New Call"
'Filter the relevant Contcode
ActiveSheet.Range("$A$1:$P$1315").AutoFilter Field:=13, Criteria1:=Array( _
"MOT", "Service", "Service & MOT"), Operator:=xlFilterValues
'Filter by person
ActiveSheet.Range("$A$1:$P$1315").AutoFilter Field:=16, Criteria1:= _
"Bethan"
'Select top 50 and paste to Sheet 2
Range("A1:A395").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
Last edited: