The following code runs very slow with a 3-second pause after the "end if", before the "next row". Does anyone have any ideas on how to speed it up?
Code:
Sub TryThis()
Application.ScreenUpdating = False
' Paste Data
Range("C1").Select
ActiveSheet.Paste
' Parse to item level records
totalrows = ActiveSheet.UsedRange.Rows.Count
Range(Cells(21, 1), Cells(totalrows, 1)).FormulaR1C1 = _
"=IF(OR(RIGHT(RC[2],8)=""Standard"",RIGHT(RC[2],13)=""Expense Repor"",RIGHT(RC[2],11)=""Credit Memo"",RIGHT(RC[2],10)=""Prepayment"",RIGHT(RC[2],10)=""Debit Memo""),RC[2],R[-1]C)"
Columns("A:A").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
' Remove Headers
totalrows = ActiveSheet.UsedRange.Rows.Count
Range(Cells(1, 2), Cells(totalrows, 2)).FormulaR1C1 = "=IF(OR(LEFT(RC[1],6)="" Item"",LEFT(RC[1],6)="" Misc"",LEFT(RC[1],6)="" Frei"",LEFT(RC[1],6)="" Prep"",LEFT(RC[1],5)="" Tax""),"""",""Delete"")"
Columns("B:B").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
For Row = totalrows To 1 Step -1
If Cells(Row, 2).Value = "Delete" Then
Rows(Row).Delete
End If
Next Row
Application.ScreenUpdating = True
End Sub