Hey Guys!
Any ideas on how to speed this macro up?
![]()
Please Login or Register to view this content.
Also, any tips on how to speed up my macros and excel in General? Thanks!
Hey Guys!
Any ideas on how to speed this macro up?
![]()
Please Login or Register to view this content.
Also, any tips on how to speed up my macros and excel in General? Thanks!
May be this...
![]()
Please Login or Register to view this content.
If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
Mark your thread as Solved
If the suggestion helps you, then Click *below to Add Reputation
A standard way to speed up macros is to turn off screen updating. You'll notice the screen flickers as Excel displays each output of the macro, considerably slowing down the start-finish time. To resolve this, start your macro with:
Application.ScreenUpdating = False
and end it with
Application.ScreenUpdating = True
Hope this helps
Matt
Optimize Slow Code in VBA
Speed up VBA Code
Not that it is slowing your code down, but your first Select Case statement is useless as it does nothing, but it still must be read and processed.
Rather than looping, use AutoFilter and delete all visible rows in one step. It is faster to loop through a short list of filter criteria than every single cell.
In VBA, it is seldom, if ever, necessary to Activate or Select sheets/ranges/cells, etc. - - just act on them directly
Example using AutoFilter![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
Last edited by Palmetto; 07-02-2013 at 07:34 AM. Reason: slight revision to code
Palmetto
Do you know . . . ?
You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.
perhaps
![]()
Please Login or Register to view this content.
Josie
if at first you don't succeed try doing it the way your wife told you to
Thanks a lot to everyone!
Palmetto, how would you implement that on the attached sheet? it seems like checking cell by cell is far too slow...
Cell-by-cell checking is exactly what your current code is doing.
Perhaps I am missing it, but I don't see where you have clearly established your criteria for deleting rows.
Your code, which doesn't/shouldn't work (because it loops in the wrong direction) just deleting all rows.
Once you define your criteria for which rows to delete, I (or others) can provide some help.
That is what my code example shows. By defning the entire range and filtering it for, say, RF_CORP_TMT, this line of code would delete all rows at once.how would you implement that on the attached sheet.
We could then pass another criteria to the filter to continue deleting groups of records, looping only through a short list of criteria and not cell-by-cell.![]()
Please Login or Register to view this content.
Thanks for the help, I have tried to implement it in order two filter out two different criterias, but I get a type mismatch error.
Could you tell me what I am doing wrong? Thanks
Well . . you tried to use my code as is and it was provided only as an example - not the solution since I did not have your workbook when I wrote it.
You placed the code in the ThisWorkbook module, but it should be placed in a standard module.
Attached is a working example. I opted to maintain a criteria list on a separate sheet as this approach provides more flexibility for a criteria list than hardcoding a list and using an array. If your criteria list will always be the same, then you might want to use an array of values.
Included in this version is an option to clear the criteria list on sheet2. Sheet references are to sheet code names, so change them as needed.
![]()
Please Login or Register to view this content.
Excel_Forum_DeleteRows.xlsm
![]()
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks