blopib Posted July 1, 2011 Report Share Posted July 1, 2011 Hi I've made a really simple macro that marks as many rows as I define when prompted and put it in a variable. But why is it so slow? It doesn't seem to help adjusting the general delay or even run the macro a 1000 times faster. Why is this? Is it because the use of variables? I've tried to run the macro against files on both lokal and serverplaces but it's the same result. The reason behind this is intresting for some of the other macros that I have made, so it would be nice if someone have a solution or could explain this to me. (The code is not normaly used with Excel but it is the same problem) <IVAR2:01:02:FDefine the number of loops to runFFCenter:Center><MMS2:1050,10><REP3:05:000001:000001:0001:0:01:><TBOX4:T:6:0Right000Top000200000100:000:Number of loopsNumber of loops to run: %N1% Number of loops done: %N2%><ACTIVATE2:Microsoft Excel -><WAITWIN2:000010:000000:Microsoft Excel -><TEXTTYPE:<SHIFT><ARROW DOWN>><WAITMOUSE:000010:000000:Arrow><NMVAR:08:02:0:0000001:0:0000000><TBCLOSE:Number of loops><ENDREP> Regards Quote Link to comment Share on other sites More sharing options...
blopib Posted August 15, 2011 Author Report Share Posted August 15, 2011 No ideas? Something I should do different? Quote Link to comment Share on other sites More sharing options...
paul Posted August 15, 2011 Report Share Posted August 15, 2011 Why is your loop so slow? Within each iteration of the loop: - you are doing a text box display and close - you are doing a Window Activate and Wait For Window - you are doing a Wait for Mouse Cursor - you are extending a selection of cells instead of selecting the start and shift-selecting the end cell just once And it doesn't run reliably on my machine, probably because you are typing stuff too quickly for the macro to react properly. You could rewrite this macro to remove the loop and do your operation just once, as in: - solicit the number of cells you want to select - click on the 1st cell - move to the last cell - do a shift-click There are even better ways to do this using Excel objects and methods, but it shouldn't be necessary to use that approach here. Quote Link to comment Share on other sites More sharing options...
blopib Posted August 16, 2011 Author Report Share Posted August 16, 2011 Thanks for your reply Paul. As I said I don't normally use this in Excel, it's for the use in another program. The idea is to mark a predefined number of rows that I what to handle, and then shift to other windows within the program. If I take a to big bite, it gets to much for the program to handle. Maybe I could work something out to do this in a better way, but right now I stuck with my thoughts about why my loop doesn't work as I expect. I've looked into the code in my post again and I still can't see the reason why it takes so long time to roll through. The code is so small that this should take no time at all, as I see it. Is it because of the use of variables or what? Please could someone bring some light into this so I can sleep at night. :-) I bit more serious I think this would explain somethings about other macros that i use. Regards Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.