My code to format my sheets is below, but it runs very very slowly....any way I can make this more streamlined?
![]()
Please Login or Register to view this content.
My code to format my sheets is below, but it runs very very slowly....any way I can make this more streamlined?
![]()
Please Login or Register to view this content.
Getting rid of all the Select/Selection in the code might speed things up a bit.
However, I think the main bottleneck is the two loops.
Not sure what you can do about them.
If posting code please use code tags, see here.
Hi nickmax1,
Try to avoid interactive command like ".Select"
for example instead of
use![]()
Please Login or Register to view this content.
Try this and if you still have problem let us know![]()
Please Login or Register to view this content.
aelgadi
> Click Star if I helped. Thanks
What I notice is that you first select a range and then apply the formatting to the range. This is often not really necessary as you can apply formatting also with physically selecting the cells. I have personally found the latter method to be quicker. I have re-written some of the code and on my PC it runs in less than a second
![]()
Please Login or Register to view this content.
invalid use of property when i change . select to .font
??
Hi Nick,
I have made all the changes needed in the code I posted above which runs without any errors
The macrorecorder is not that smart. Apart from using Select all the time it also records all properties even though just one or two has been changed.
Since you start by clearing the format on the whole range you can delete all the formatting commands that just sets the values to their defaults.
The first bunch of lines looking like this:
could be changed into something like this:![]()
Please Login or Register to view this content.
Note also the dim x statement. That tells VBA that I'm gonna use a variable named x and that it will contain a range. This saves a little bit of memory and speeds things up just a little bit.![]()
Please Login or Register to view this content.
I haven't tested this code and I may have deleted some rows that were not the defaults but hopefully it will give you some leads anyway.
<----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left
If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.
thanks Olaf,
it seems to run a little quicker, about a minute on my machine. It was about 2 minutes before that.
thanks Jacc that shaves of a bit of time as well getting rid of the pointless macrorecorder code.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks