Hello Experts
Whats wrong with my code ?
ThanksPlease Login or Register to view this content.
Sharky
Hello Experts
Whats wrong with my code ?
ThanksPlease Login or Register to view this content.
Sharky
Last edited by Sharky Amit; 04-20-2009 at 05:36 AM.
When you delete rows you should work in reverse - bottom up...
If you consider you have rows 2:10 and you loop from 2 to 10, when you delete row 3 then what was row 4 is now 3 yet you miss it as you go to 4 (which was 5), make sense ?
Better then to adopt something along the lines of:
Please Login or Register to view this content.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Exactly right...and if you're deleting a LOT of rows, then the code will execute much faster if you turn off the screenupdating:
Please Login or Register to view this content.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
?None of us is as good as all of us? - Ray Kroc
?Actually, I *am* a rocket scientist.? - JB (little ones count!)
If speed were a concern then I would make the point that as much as ScreenUpdating will slow code, given Deletion of Rows is a Volatile action if you have Volatile functions you're best served forcing Calculation to Manual prior to implementation of Deletion Loop and restoring Calc to it's former setting on completion ... and if you do that you may as well do all three, ie: screenupdate, calculation & events.
An example below:
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks