surfdoc37
New Member
- Joined
- Mar 12, 2004
- Messages
- 23
- Office Version
- 2019
- 2013
- Platform
- Windows
- MacOS
Hello and apologies for maybe not having the clearest formatting here. I would like to combine several small macros, which sort out some rows from a sheet, copy them, and paste them into a new blank sheet. Because I am lazy I would like to use one macro to perform the task instead of using the six small macros which do work just fine individually. Macros are all basically the same, only the sort criteria changes. In the VBA editor they are separated by a horizontal line if that matters.
_______________________________________________________
Sub make_C_sheet()
'
' make_C_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*C*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
Sub make_1B_sheet()
'
' make_1B_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*1B*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
Sub make_2B_sheet()
'
' make_2B_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*2B*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
Sub make_SS_sheet()
'
' make_SS_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*SS*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
Sub make_3B_sheet()
'
' make_3B_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*3B*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
Sub make_OF_sheet()
'
' make_OF_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*OF*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
_______________________________________________________
I searched and found the following which looks like it might be a macro to run sequential macros. But not sure how to adapt it, or, whether that is better than just having one great big macro.
_______________________________________________________
Sub Run_A_Procedures()
Call ModuleName.ProcedureName
Call ModuleName.A_1001_Prepare_Sheet
Call ModuleName.A_1002_MergeMultipleWorkbooks
Call ModuleName.A_1003_DeleteSheets1
Call ModuleName.A_1004_Rename_Sheet_after_Workbook_Name
End Sub
__________________________________________________________________
Appreciate any assistance!
_______________________________________________________
Sub make_C_sheet()
'
' make_C_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*C*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
Sub make_1B_sheet()
'
' make_1B_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*1B*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
Sub make_2B_sheet()
'
' make_2B_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*2B*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
Sub make_SS_sheet()
'
' make_SS_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*SS*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
Sub make_3B_sheet()
'
' make_3B_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*3B*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
Sub make_OF_sheet()
'
' make_OF_sheet Macro
'
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AG$653").AutoFilter Field:=3, Criteria1:="=*OF*", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").ColumnWidth = 18
Range("A1").Select
End Sub
_______________________________________________________
I searched and found the following which looks like it might be a macro to run sequential macros. But not sure how to adapt it, or, whether that is better than just having one great big macro.
_______________________________________________________
Sub Run_A_Procedures()
Call ModuleName.ProcedureName
Call ModuleName.A_1001_Prepare_Sheet
Call ModuleName.A_1002_MergeMultipleWorkbooks
Call ModuleName.A_1003_DeleteSheets1
Call ModuleName.A_1004_Rename_Sheet_after_Workbook_Name
End Sub
__________________________________________________________________
Appreciate any assistance!