Hi everyone... I wonder if someone could look at my macro below... It kind-of stops working at row # 3. Is there something I am missing?
Code:
Sub Weekly_Projects_Report()
' This Macro is used for formatting the weekly projects status report.
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("A1:O1").Select
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
.PatternTintAndShade = 0
End With
With Range("A1").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
End With
With Columns("K:M").Select
Selection.Style = "Currency"
End With
ActiveSheet.Range(Range("A1"), Range("O1").End(xlDown).Offset(0, 1)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.6)
.BottomMargin = Application.InchesToPoints(0.6)
.HeaderMargin = Application.InchesToPoints(0.25)
.FooterMargin = Application.InchesToPoints(0.25)
.Orientation = xlLandscape
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
End With
Range("A1").Select
Columns("A:A").ColumnWidth = 12
Columns("B:B").ColumnWidth = 20.5
Columns("C:C").ColumnWidth = 16.5
Columns("I:I").ColumnWidth = 16.5
Columns("J:J").ColumnWidth = 15.5
Columns("K:K").ColumnWidth = 14.5
Columns("L:L").ColumnWidth = 13
Columns("M:M").ColumnWidth = 12
Columns("N:N").ColumnWidth = 9.15
Cells.Select
Cells.EntireRow.AutoFit
ActiveSheet.Range(Range("A1"), Range("O1").End(xlDown).Offset(0, 1)).Select
With Selection
.VerticalAlignment = xlCenter
.WrapText = True
End With
ActiveSheet.Range(Range("A1"), Range("O1").End(xlDown).Offset(0, 1)).Select
With Selection.Font
.Name = "Calibri"
.Size = 10
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "Pending Projects Report As Of: &D"
.RightHeader = ""
.LeftFooter = "&BCitigroup Confidential&B"
.CenterFooter = "&D"
.RightFooter = "Page &P"
End With
Rows("1:1").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
.PrintTitleColumns = ""
End With
With ActiveWorkbook.Worksheets("Search Projects")
.Range("A1").CurrentRegion.Sort Key1:=.Range("I2"), Order1:=xlAscending, Key2:=.Range("N2") _
, Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False _
, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:= _
xlSortNormal
End With
With Sheets("Search Projects").Select
Columns("D").EntireColumn.Hidden = True
Columns("E").EntireColumn.Hidden = True
Columns("F").EntireColumn.Hidden = True
Columns("G").EntireColumn.Hidden = True
Columns("H").EntireColumn.Hidden = True
Columns("O").EntireColumn.Hidden = True
Columns("P").Delete
End With
Sheets("Search Projects").Select
Sheets("Search Projects").Copy Before:=Sheets(1)
Sheets("Search Projects (2)").Name = "Completed"
Sheets("Completed").Tab.ColorIndex = 39
Sheets("Completed").Select
For i = LR To 2 Step -1
If Range("N" & i).Value = "Draft" Then
Rows(i).Delete
End If
If Range("N" & i).Value = "In Progress" Then
Rows(i).Delete
End If
If Range("N" & i).Value = "On Hold" Then
Rows(i).Delete
End If
If Range("N" & i).Value = "Next Year Plan" Then
Rows(i).Delete
End If
If Range("N" & i).Value = "Not Started" Then
Rows(i).Delete
End If
Next i
Sheets("Search Projects").Select
For i = LR To 2 Step -1
If Range("N" & i).Value = "Complete" Then
Rows(i).Delete
End If
Next i
Sheets("Search Projects").Name = "Pending"
With ActiveWorkbook.Sheets("Pending").Tab
.Color = 5296274
.TintAndShade = 0
End With
End Sub