fabiogiallo
New Member
- Joined
- Mar 1, 2018
- Messages
- 6
Good afternoon,
i am using the code below to copy some data from a "master" sheet, selected using a filter, to another "Bp" sheet.
What i need to do is:
apply filters at 2nd, 3rd, 4th columns, then the next column (5th) has to be filtered to remove empty cell, select the data (they increase day by day) and paste them to a new column in Bp sheet. Same procedure for the following colums: filter to eliminate empty cells, select all, copy and paste to another column in to next column in Bp sheet and so on.
The code is working but i was wondering if there is better way to write the code and make the worksheet faster and lighter.
Thank you.
i am using the code below to copy some data from a "master" sheet, selected using a filter, to another "Bp" sheet.
What i need to do is:
apply filters at 2nd, 3rd, 4th columns, then the next column (5th) has to be filtered to remove empty cell, select the data (they increase day by day) and paste them to a new column in Bp sheet. Same procedure for the following colums: filter to eliminate empty cells, select all, copy and paste to another column in to next column in Bp sheet and so on.
The code is working but i was wondering if there is better way to write the code and make the worksheet faster and lighter.
Thank you.
Code:
Sub BP1andBP2_6I6N()
'
' BP1andBP2_6I6N Macro
'
Application.ScreenUpdating = False
ActiveSheet.Range("$A$3:$AR$30002").AutoFilter Field:=2, Criteria1:=Array( _
"Bp1", "Bp1c", "Bp1d", "Bp2"), _
Operator:=xlFilterValues
ActiveSheet.Range("$A$3:$AR$30002").AutoFilter Field:=3, Criteria1:= _
"class 6"
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=4, Criteria1:="<>"
Range("D4:E30002").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("A7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=4
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=6, Criteria1:="<>"
Range("F04:G30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("C7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=6
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=8, Criteria1:="<>"
Range("H04:K30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("E7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=8
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=12, Criteria1:="<>"
Range("L04:N30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("I7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=12
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=15, Criteria1:="<>"
Range("O4:Q30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("L7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=15
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=18, Criteria1:="<>"
Range("R4:S30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("O7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=18
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=24, Criteria1:="<>"
Range("X4:Y30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("U7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=24
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=26, Criteria1:="<>"
Range("Z4:AA30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("W7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=26
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=28, Criteria1:="<>"
Range("AB4:AC30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("Y7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=28
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=30, Criteria1:="<>"
Range("AD4:AG30002").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("AA7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=30
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=34, Criteria1:="<>"
Range("AH4:AG30002").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("AE7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=34
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=37, Criteria1:="<>"
Range("AK4:AL30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("AH7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=37
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=39, Criteria1:="<>"
Range("AM1904:AN1904").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("AJ7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=39
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=41, Criteria1:="<>"
Range("AO4:AP30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("AL7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=41
ActiveSheet.Range("$A$3:$AP$30002").AutoFilter Field:=43, Criteria1:="<>"
Range("AQ4:AR30002").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("BP1 and BP2 6I 6N").Select
Range("AN7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("master").Select
ActiveSheet.ShowAllData
Range("A4").Select
Sheets("BP1 and BP2 6I 6N").Select
Range("A4").Select
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: