Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub total()
- Application.Volatile
- Dim Audit() As Variant
- Dim i As Long
- Sheets("Input").Select
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Sheets("SecretEval1").Visible = True
- Audit = Array("PM", "MSU", "SPF", "FUL", "LDB", "CONT", "T-GCL", "GBUY", "EXTRA")
- 'Unhides array worksheets
- For i = LBound(Audit) To UBound(Audit)
- Sheets(Audit(i)).Visible = True
- Next
- DoEvents
- 'Clears potential content on array sheets
- For i = LBound(Audit) To UBound(Audit)
- Sheets(Audit(i)).Cells.Clear
- Next
- DoEvents
- 'copies the desired columns into their respective sheets
- For i = LBound(Audit) To UBound(Audit)
- Call CallUpon(Audit(i))
- DoEvents
- Next
- 'Autofits the columns of each sheet
- For i = LBound(Audit) To UBound(Audit)
- ThisWorkbook.Worksheets(Audit(i)).Cells.EntireColumn.AutoFit
- Next
- DoEvents
- Sheets("PM").Select
- Sheets("SecretEval1").Delete
- Sheets("Macro").Delete
- Sheets("Input").Delete
- ActiveWorkbook.Sheets.Copy
- Call closeit
- Workbooks("Audit_Workbook").Activate
- ActiveWorkbook.Close False
- End Sub
- Sub CallUpon(crit)
- 'Selects sheet and applies filter
- Sheets("SecretEval1").Select
- Cells.AutoFilter
- ActiveSheet.Range("$A$1:$X$10000").AutoFilter Field:=17, Criteria1:=crit 'variable
- Select Case crit
- Case Is = "PM"
- Range("A:D, G:I, K:L, M:N").Copy Destination:=Sheets(crit).Columns(1)
- Case Is = "MSU"
- Range("A:G,I:I, L:N").Copy Destination:=Sheets(crit).Columns(1)
- Case Is = "SPF"
- Range("A:D, I:I, L:M").Copy Destination:=Sheets(crit).Columns(1)
- Case Is = "FUL"
- Range("A:D, I:I, M:M").Copy Destination:=Sheets(crit).Columns(1)
- Case Is = "LDB"
- Range("A:F, I:I, L:N").Copy Destination:=Sheets(crit).Columns(1)
- Case Is = "CONT"
- Range("A:G, I:K, L:N").Copy Destination:=Sheets(crit).Columns(1)
- Case Is = "T-GCL"
- Range("A:G, N:N").Copy Destination:=Sheets(crit).Columns(1)
- Case Is = "GBUY"
- Range("A:G,I:I, L:M").Copy Destination:=Sheets(crit).Columns(1)
- Case Is = "EXTRA"
- Range("A:D").Copy Destination:=Sheets(crit).Columns(1)
- End Select
- DoEvents
- Sheets(crit).Select
- Sheets("SecretEval1").Select
- Cells.AutoFilter
- End Sub
Add Comment
Please, Sign In to add comment