Guest User

Untitled

a guest
Jan 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. Sub total()
  2. Application.Volatile
  3. Dim Audit() As Variant
  4. Dim i As Long
  5.  
  6. Sheets("Input").Select
  7. Application.ScreenUpdating = False
  8. Application.DisplayAlerts = False
  9. Sheets("SecretEval1").Visible = True
  10. Audit = Array("PM", "MSU", "SPF", "FUL", "LDB", "CONT", "T-GCL", "GBUY", "EXTRA")
  11.  
  12. 'Unhides array worksheets
  13. For i = LBound(Audit) To UBound(Audit)
  14. Sheets(Audit(i)).Visible = True
  15. Next
  16.  
  17. DoEvents
  18.  
  19.  
  20. 'Clears potential content on array sheets
  21. For i = LBound(Audit) To UBound(Audit)
  22. Sheets(Audit(i)).Cells.Clear
  23. Next
  24.  
  25. DoEvents
  26.  
  27. 'copies the desired columns into their respective sheets
  28. For i = LBound(Audit) To UBound(Audit)
  29. Call CallUpon(Audit(i))
  30. DoEvents
  31. Next
  32.  
  33. 'Autofits the columns of each sheet
  34. For i = LBound(Audit) To UBound(Audit)
  35. ThisWorkbook.Worksheets(Audit(i)).Cells.EntireColumn.AutoFit
  36. Next
  37.  
  38. DoEvents
  39.  
  40. Sheets("PM").Select
  41. Sheets("SecretEval1").Delete
  42. Sheets("Macro").Delete
  43. Sheets("Input").Delete
  44. ActiveWorkbook.Sheets.Copy
  45. Call closeit
  46. Workbooks("Audit_Workbook").Activate
  47. ActiveWorkbook.Close False
  48. End Sub
  49.  
  50. Sub CallUpon(crit)
  51. 'Selects sheet and applies filter
  52. Sheets("SecretEval1").Select
  53.  
  54. Cells.AutoFilter
  55. ActiveSheet.Range("$A$1:$X$10000").AutoFilter Field:=17, Criteria1:=crit 'variable
  56. Select Case crit
  57. Case Is = "PM"
  58.  
  59. Range("A:D, G:I, K:L, M:N").Copy Destination:=Sheets(crit).Columns(1)
  60. Case Is = "MSU"
  61.  
  62. Range("A:G,I:I, L:N").Copy Destination:=Sheets(crit).Columns(1)
  63. Case Is = "SPF"
  64.  
  65. Range("A:D, I:I, L:M").Copy Destination:=Sheets(crit).Columns(1)
  66. Case Is = "FUL"
  67.  
  68. Range("A:D, I:I, M:M").Copy Destination:=Sheets(crit).Columns(1)
  69. Case Is = "LDB"
  70.  
  71. Range("A:F, I:I, L:N").Copy Destination:=Sheets(crit).Columns(1)
  72. Case Is = "CONT"
  73.  
  74. Range("A:G, I:K, L:N").Copy Destination:=Sheets(crit).Columns(1)
  75. Case Is = "T-GCL"
  76.  
  77. Range("A:G, N:N").Copy Destination:=Sheets(crit).Columns(1)
  78. Case Is = "GBUY"
  79.  
  80. Range("A:G,I:I, L:M").Copy Destination:=Sheets(crit).Columns(1)
  81. Case Is = "EXTRA"
  82.  
  83. Range("A:D").Copy Destination:=Sheets(crit).Columns(1)
  84. End Select
  85.  
  86. DoEvents
  87.  
  88. Sheets(crit).Select
  89. Sheets("SecretEval1").Select
  90. Cells.AutoFilter
  91.  
  92. End Sub
Add Comment
Please, Sign In to add comment