I tried working with the code to the best of my ability but the code doesn't work:-(
I pasted my entire code including scripts that I originally omitted.
I would really appreciate if anyone can shed some light on this issue.
Thank you.
Option Explicit
Sub EXECUTE_MULTIPLE_TASKS()
Dim ws As Worksheet: Set ws = Sheets("Sheet1")
Dim lRow As Long, lCol As Long, rCell As Long
'misc
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
lCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'Part A
If IsEmpty(ws.Range(lCol - 2)) Then
ws.Range(lCol - 2).Formula = ""
ws.Range(lCol - 1).Formula = ""
End If
ws.Range(lCol - 2, lCol - 2).Resize(lRow - 18 + 1, 2).FillDown
'Part B
For rCell = lRow To 18 Step -1
If ws.Range(lCol - 3 & rCell).Value = 0 Then
ws.Range(lCol - 3 & rCell).EntireRow.Delete Shift:=xlUp
ElseIf ws.Range(lCol - 3 & rCell).Value = "" Then
ws.Range(lCol - 3 & rCell).EntireRow.Delete Shift:=xlUp
End If
Next rCell
'Part C
Rows("18:3000").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range( _
"A18:A1161"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A18:AN1161")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Cells(1, 1).Select
'Part D
lRow = ws.Range("A" & Rows.Count).End(xlUp).Row
With ws.Range("A" & lRow + 1, lCol & lRow + 1)
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Interior.Color = RGB(242, 242, 242)
End With
With ws.Range(lCol - 4 & lRow + 1)
.Value = "Total Qty"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Font.Bold = True
.Font.Name = "Cambria"
.Font.Size = 8
End With
With ws.Range(lCol - 1 & lRow + 1)
.Value = "Total Cost"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Font.Bold = True
.Font.Name = "Cambria"
.Font.Size = 8
End With
With ws.Range(lCol - 3 & lRow + 1)
.Formula = "=SUM(lCol - 3 & rCell & lRow & )"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Font.Bold = True
.Font.Name = "Cambria"
.Font.Size = 8
End With
With ws.Range("E" & lRow + 1)
.Formula = "=SUM(lCol & rCell & lRow & )"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Font.Bold = True
.Font.Name = "Cambria"
.Font.Size = 8
End With
With ws.Range("B16")
.Formula = "=SUM(lCol & rCell & lRow & )"
End With
'Part E
ws.PageSetup.PrintArea = "$A$1" & lCol & lRow + 1
'Clean Up
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Bookmarks