woodpecker2
New Member
- Joined
- Aug 2, 2007
- Messages
- 33
I've created a macro as shown below. The problem I have it takes well over an hour for it to run.
The rows that create the criteria for the LookUp are in excess of 40,000 and like wise, the area with the data that is being matched is also in excess of 40.000 rows.
I've turned off ScreenUpdating and AutoCalc, which has improved things slightly, but I need to really get it to run faster.
Can anyone help?
The rows that create the criteria for the LookUp are in excess of 40,000 and like wise, the area with the data that is being matched is also in excess of 40.000 rows.
I've turned off ScreenUpdating and AutoCalc, which has improved things slightly, but I need to really get it to run faster.
Can anyone help?
Code:
Sub Macro10()
Dim LastRow As Long
LastRow = Range("M65536").End(xlUp).Row
'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Range("H3:I3").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(LOOKUP(2,1/((RC[-6]=R3C12:R" & LastRow & "C12)*(RC[-5]=R3C13:R" & LastRow & "C13)*(RC[-4]=R3C14:R" & LastRow & "C14)),R3C18:R" & LastRow & "C18)),""No Matching PLANOP Record"",LOOKUP(2,1/((RC[-6]=R3C12:R" & LastRow & "C12)*(RC[-5]=R3C13:R" & LastRow & "C13)*(RC[-4]=R3C14:R" & LastRow & "C14)),R3C18:R" & LastRow & "C18))"
Range("H3:I3").Select
Range("I3").Activate
ActiveCell.FormulaR1C1 = "Thursday"
LastRow = Range("B65536").End(xlUp).Row
Range("H3:I3").Select
Selection.Copy
Range("H3:H" & LastRow).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Application.Calculation = xlCalculationAutomatic
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.LargeScroll ToRight:=-1
Range("B3").Select
Application.ScreenUpdating = True
End Sub