I need a new process to accomplish my needs. In the file there are 2 tabs, Make Ready & Apartments. The code scans the "Apartments" sheet to categorize 246 units and then copies only the needed rows of data to the "Make Ready" sheet, sorting them in to the appropriate section. The "Make Ready" is broken into 4 main categorizes (Rented Not Moved IN, Available to Rent, Not Ready, Notice to Vacate) and further breaks the row between 1 & 2 bedroom. This is just a tiny piece of my program but because of how slow it runs it causes major issue with it's functionality. Currently it takes anywhere from 15 seconds - 2+ Minutes to run depending on where the function is called from (I am also lost about that since it is the exact same function). Can anyone suggest a faster method as I need to get the run time down to less than a second and I am lost.
Function ReportMakeReadyFill()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Dim FRow As Long
Dim LRow As Long
Dim ColAPLast1 As Long
Dim ColAPLast2 As Long
Dim APValues As Variant
Dim MRValues As Variant
Dim AP As Worksheet
Dim MR As Worksheet
Dim UnitBtnLoc As Range
Dim UnitBtnName As String
Dim CreateBtn As Object
Set AP = Worksheets("apartments")
Set MR = Worksheets("Make Ready")
Dim CRented As Long, CRemodel As Long, CAdmin As Long, CRNMI As Long, CStatus As Long, CUnit As Long, CUnit2 As Long
Dim CTurnNotes As Long, CUnitNotes As Long, CFinal As Long, CCabinets As Long, CFridge As Long, CRange As Long
Dim CAC As Long, CTub As Long, CCLean As Long, CPaint As Long, CVynal As Long, CUporDown As Long, CITV As Long
Dim CCarpet As Long, CMaint As Long, CMoveIn As Long, CFloorPlan As Long, CMoveOutRemodel As Long, CTurn As Long
Dim MRentedMain As Long, MRented1Bed As Long, MRented2Bed As Long
Dim MAvailMain As Long, MAvail1Bed As Long, MAvail2Bed As Long
Dim MNotAvailMain As Long, MNotAvail1Bed As Long, MNotAvail2Bed As Long
Dim MNoticeMain As Long, MNotice1Bed As Long, MNotice2Bed As Long, MEndLine As Long
Dim MUnit As Long, MFloorPlan As Long, MUporDown As Long, MRemodel As Long
Dim MMoveOutRemodel As Long, MMoveIn As Long, MStatus As Long, MMaint As Long
Dim MCarpet As Long, MVynal As Long, MPaint As Long, MClean As Long, MAC As Long, MFridge As Long
Dim MRange As Long, MTub As Long, MUnitNotes As Long, MTurnNotes As Long, MFinal As Long, MCabinets As Long
With Worksheets("apartments")
ColAPLast1 = .Cells(1, Columns.Count).End(xlToLeft).Column
With .Range(.Cells(1, 1), .Cells(1, ColAPLast1))
CRented = .Find("Occupied").Column
CRNMI = .Find("RNMI").Column
CAdmin = .Find("Admin").Column
CTurn = .Find("Turned").Column
CITV = .Find("ITV").Column
CFloorPlan = .Find("Floor Plan").Column
CUnit = .Find("Apartment").Column
CUnit2 = .Find("Apartment 2").Column
CUporDown = .Find("Up or Down").Column
CRemodel = .Find("Remodel").Column
CMoveOutRemodel = .Find("Turn/RM Start").Column
CMoveIn = .Find("Move In").Column
CStatus = .Find("Status").Column
CMaint = .Find("Maintenance").Column
CCarpet = .Find("Carpet").Column
CVynal = .Find("Vinyl").Column
CPaint = .Find("Painted").Column
CCLean = .Find("Clean").Column
CAC = .Find("AC").Column
CFridge = .Find("Fridge").Column
CRange = .Find("Range").Column
CTub = .Find("Tub").Column
CCabinets = .Find("Cabinets").Column
CUnitNotes = .Find("Unit Notes").Column
CFinal = .Find("Final Inspec").Column
CTurnNotes = .Find("Turn Notes").Column
End With
End With
With Worksheets("Make Ready")
ColAPLast2 = .Cells(1, Columns.Count).End(xlToLeft).Column
With .Range(.Cells(1, 1), .Cells(1, ColAPLast2))
MUnit = .Find("Unit").Column
MFloorPlan = .Find("Floor").Column
MUporDown = .Find("UpDown").Column
MRemodel = .Find("Remodel").Column
MMoveOutRemodel = .Find("Mo/Re Date").Column
MMoveIn = .Find("Move in").Column
MStatus = .Find("Status").Column
MMaint = .Find("Maint").Column
MCarpet = .Find("Carpet").Column
MVynal = .Find("Vynal").Column
MPaint = .Find("Paint").Column
MClean = .Find("Clean").Column
MAC = .Find("AC").Column
MFridge = .Find("Fridge").Column
MRange = .Find("Range").Column
MTub = .Find("Tub").Column
MCabinets = .Find("Cabinets").Column
MUnitNotes = .Find("Unit Notes").Column
MFinal = .Find("Final").Column
MTurnNotes = .Find("Turn Notes").Column
End With
End With
With Worksheets("apartments")
APValues = .Range(.Cells(1, 1), .Cells(250, ColAPLast1)).Value
End With
With Worksheets("Make Ready")
MRValues = .Range(.Cells(1, 1), .Cells(250, ColAPLast2)).Value
End With
For FRow = 2 To 247
With MR.Range("A1:A247")
MRentedMain = .Find("RentedMain").Row
MRented1Bed = .Find("Rented1Bed").Row
MRented2Bed = .Find("Rented2Bed").Row
MAvailMain = .Find("AvailableMain").Row
MAvail1Bed = .Find("Available1Bed").Row
MAvail2Bed = .Find("Available2Bed").Row
MNotAvailMain = .Find("NotAvailableMain").Row
MNotAvail1Bed = .Find("NotAvailable1Bed").Row
MNotAvail2Bed = .Find("NotAvailable2Bed").Row
MNoticeMain = .Find("NoticeMain").Row
MNotice1Bed = .Find("Notice1Bed").Row
MNotice2Bed = .Find("Notice2Bed").Row
MEndLine = .Find("EndLine").Row
End With
On Error Resume Next
If APValues(FRow, CAdmin) = "" And APValues(FRow, CRNMI) = "" And APValues(FRow, CITV) = "" _
And APValues(FRow, CTurn) = "" And APValues(FRow, CRented) = "" Then
If APValues(FRow, CFloorPlan) = "1x1 W/D" Or APValues(FRow, CFloorPlan) = "1x1" Then
LRow = ((MNotAvail2Bed - MNotAvail1Bed) - 2) + MNotAvail1Bed
MR.Cells(MNotAvail2Bed, 1).Offset(-1).EntireRow.Insert
MNotAvail1Bed = MNotAvail1Bed + 1
Else: APValues(FRow, CFloorPlan) = "2x1"
LRow = ((MNoticeMain - MNotAvail2Bed) - 2) + MNotAvail2Bed
MR.Cells(MNoticeMain, 1).Offset(-1).EntireRow.Insert
MNotAvail2Bed = MNotAvail2Bed + 1
End If
ElseIf APValues(FRow, CAdmin) = "" And APValues(FRow, CRNMI) = "" And APValues(FRow, CITV) = "" _
And APValues(FRow, CTurn) = "X" And APValues(FRow, CRented) = "" Then
If APValues(FRow, CFloorPlan) = "1x1 W/D" Or APValues(FRow, CFloorPlan) = "1x1" Then
LRow = ((MAvail2Bed - MAvail1Bed) - 2) + MAvail1Bed
MR.Cells(MAvail2Bed, 1).Offset(-1).EntireRow.Insert
MAvail1Bed = MAvail1Bed + 1
Else: APValues(FRow, CFloorPlan) = "2x1"
LRow = ((MNotAvailMain - MAvail2Bed) - 2) + MAvail2Bed
MR.Cells(MNotAvailMain, 1).Offset(-1).EntireRow.Insert
MAvail2Bed = MAvail2Bed + 1
End If
ElseIf APValues(FRow, CAdmin) = "" And APValues(FRow, CRNMI) = "" And APValues(FRow, CITV) = "X" _
And APValues(FRow, CTurn) = "" And APValues(FRow, CRented) = "X" Then
If APValues(FRow, CFloorPlan) = "1x1 W/D" Or APValues(FRow, CFloorPlan) = "1x1" Then
LRow = ((MNotice2Bed - MNotice1Bed) - 2) + MNotice1Bed
MR.Cells(MNotice2Bed, 1).Offset(-1).EntireRow.Insert
MNotice1Bed = MNotice1Bed + 1
Else: APValues(FRow, CFloorPlan) = "2x1"
LRow = ((MEndLine - MNotice2Bed) - 2) + MNotice2Bed
MR.Cells(MEndLine, 1).Offset(-1).EntireRow.Insert
MNotice2Bed = MNotice2Bed + 1
End If
ElseIf APValues(FRow, CAdmin) = "" And APValues(FRow, CRNMI) = "X" And APValues(FRow, CITV) = "" _
And APValues(FRow, CRented) = "" Then
If APValues(FRow, CFloorPlan) = "1x1 W/D" Or APValues(FRow, CFloorPlan) = "1x1" Then
LRow = ((MRented2Bed - MRented1Bed) - 2) + MRented1Bed
MR.Cells(MRented2Bed, 1).Offset(-1).EntireRow.Insert
MRented1Bed = MRented1Bed + 1
Else: APValues(FRow, CFloorPlan) = "2x1"
LRow = ((MAvailMain - MRented2Bed) - 2) + MRented2Bed
MR.Cells(MAvailMain, 1).Offset(-1).EntireRow.Insert
MRented2Bed = MRented2Bed + 1
End If
End If
If LRow = 0 Then
Else
MR.Cells(LRow, MUnit).Value = AP.Cells(FRow, CUnit).Value
MR.Cells(LRow, MFloorPlan).Value = AP.Cells(FRow, CFloorPlan).Value
MR.Cells(LRow, MUporDown).Value = AP.Cells(FRow, CUporDown).Value
MR.Cells(LRow, MRemodel).Value = AP.Cells(FRow, CRemodel).Value
MR.Cells(LRow, MMoveOutRemodel).Value = AP.Cells(FRow, CMoveOutRemodel).Value
MR.Cells(LRow, MMoveIn).Value = AP.Cells(FRow, CMoveIn).Value
MR.Cells(LRow, MStatus).Value = AP.Cells(FRow, CStatus).Value
MR.Cells(LRow, MMaint).Value = AP.Cells(FRow, CMaint).Value
MR.Cells(LRow, MCarpet).Value = AP.Cells(FRow, CCarpet).Value
MR.Cells(LRow, MVynal).Value = AP.Cells(FRow, CVynal).Value
MR.Cells(LRow, MPaint).Value = AP.Cells(FRow, CPaint).Value
MR.Cells(LRow, MClean).Value = AP.Cells(FRow, CCLean).Value
MR.Cells(LRow, MAC).Value = AP.Cells(FRow, CAC).Value
MR.Cells(LRow, MFridge).Value = AP.Cells(FRow, CFridge).Value
MR.Cells(LRow, MRange).Value = AP.Cells(FRow, CRange).Value
MR.Cells(LRow, MTub).Value = AP.Cells(FRow, CTub).Value
MR.Cells(LRow, MCabinets).Value = AP.Cells(FRow, CCabinets).Value
MR.Cells(LRow, MUnitNotes).Value = AP.Cells(FRow, CUnitNotes).Value
MR.Cells(LRow, MFinal).Value = AP.Cells(FRow, CFinal).Value
MR.Cells(LRow, MTurnNotes).Value = AP.Cells(FRow, CTurnNotes).Value
Set UnitBtnLoc = MR.Cells(LRow, MUnit)
UnitBtnName = MR.Cells(LRow, MUnit).Value
Sheets("Make Ready").Select
Set CreateBtn = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
Link:=False, DisplayAsIcon:=False, Left:=UnitBtnLoc.Left, Top:=UnitBtnLoc.Top, Width:=UnitBtnLoc.Width, Height:=UnitBtnLoc.Height)
CreateBtn.Name = "CB" & UnitBtnName
CreateBtn.Object.Caption = UnitBtnName
LRow = 0
End If
Next FRow
Worksheets("Make Ready").Activate
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
Set ActiveSheet = "Make Ready"
End Function