I have this bit of code that Deletes all the unnecessary rows from my data sheet. On my other workbooks that use this nearly identical code, it runs in seconds.. Sometimes 5-10 seconds if there are a few calculations/formulas.
I got tasked to do the same thing for a large workbook that has a hidden sheet with a TON of calculations on it. Nearly 40K formulas and validation checks at last check.
My problem is, now my lovely bit of code slows down to a crawl. Taking upwards of 10 minutes to clean up the RawData before processing with other macros. The other macros work perfectly fine. Just this one seems to slow everything down.
Please help me clean this up so it runs much faster
I know the above two formulas can be combined into one but I lack the skill needed to combine them. Even if only one of them is running, the macro takes 8+ minutes on this report. So just combining them isn't going to save much time. The first cleans up 4800 rows to about 500 give or take. The second cleans up to about 140 rows or so.
Additional Notes: The ALLDATA worksheet has 320 Plus columns and 4800 rows and both are expanding on a daily and monthly basis.
Like I said above, the other macros on this report works fast and with no problems.
Any help or ideas would be appreciated. If nothing can be done to speed up the above code, can we edit it to possibly run from the original pulled worksheet before it's copy/pasted into this workbook? Then create some code to place it into the ALLDATA worksheet of this report. Just throwing out ideas. I don't have the skills required to do this or I would. Thanks for understanding.
I got tasked to do the same thing for a large workbook that has a hidden sheet with a TON of calculations on it. Nearly 40K formulas and validation checks at last check.
My problem is, now my lovely bit of code slows down to a crawl. Taking upwards of 10 minutes to clean up the RawData before processing with other macros. The other macros work perfectly fine. Just this one seems to slow everything down.
Please help me clean this up so it runs much faster
Code:
Sub aALLDATA_Filter()
Dim ALLDATA As Worksheet 'Data Dump from ******.com comes in Unfiltered
Dim LastRow As Long 'Used to find the last row in ALLDATA.
Dim iRow As Long
Dim jRow As Long '
Set ALLDATA = Sheets("ALLDATA") 'Data Dump worksheet
'====SCREEN UPDATE TURN OFF===
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.CutCopyMode = False
Sheets("ALLDATA").Select
'====Delete Rows from Column AJ and AI on ALLDATA===
LastRow = ALLDATA.Cells.Find("*", , xlFormulas, xlPart, xlByRows, xlPrevious).Row
For iRow = LastRow To 2 Step -1
If Cells(iRow, "AJ") <> "N" Then 'Deletes everything but N status
Rows(iRow).Delete
End If
Next iRow
LastRow = ALLDATA.Cells.Find("*", , xlFormulas, xlPart, xlByRows, xlPrevious).Row
For jRow = LastRow To 2 Step -1
If ALLDATA.Cells(jRow, "AI") <> "" Then 'Skips over rows with Blank Dates in AI as these are good
If Application.WorksheetFunction.EoMonth(Date, -1) + 1 > Month(ALLDATA.Cells(jRow, "AI").Value) And Date - ALLDATA.Cells(jRow, "AI").Value > 15 Then 'Deletes any Row that is past 15 days from Current Date or Deletes Dates prior to current Month
Rows(jRow).Delete
End If
End If
Next
'====SCREEN UPDATE TURN ON===
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
I know the above two formulas can be combined into one but I lack the skill needed to combine them. Even if only one of them is running, the macro takes 8+ minutes on this report. So just combining them isn't going to save much time. The first cleans up 4800 rows to about 500 give or take. The second cleans up to about 140 rows or so.
Additional Notes: The ALLDATA worksheet has 320 Plus columns and 4800 rows and both are expanding on a daily and monthly basis.
Like I said above, the other macros on this report works fast and with no problems.
Any help or ideas would be appreciated. If nothing can be done to speed up the above code, can we edit it to possibly run from the original pulled worksheet before it's copy/pasted into this workbook? Then create some code to place it into the ALLDATA worksheet of this report. Just throwing out ideas. I don't have the skills required to do this or I would. Thanks for understanding.
Last edited: