473,395 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Excel slows down while using looping code

Hi

I'm using the following code in an Excel 2003 (Windows XP) Macro to populate formulas down the rows of a spreadsheet a certain number of times (variable - numContacts). Everything works fine to begin with as the macro adds rows very rapidly, but after about 3000 lines, it starts to slow down. nunContacts is around the 22,000 figure so with this number of rows to add to two tabs on a report, it takes roughly 16 hours to finish the macro running.

I've found code that suggests saving the spreadsheet after a number of iterations but this doesn't appear to make the code run any faster after the file saves. I've also tried to add all the rows in one go, but I get the error '4008: Selection too large'.

Can anybody help me speed this up?

Cheers

S.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~
Application.Calculation = xlManual

For pasteLoop = 2 To numContacts

Range("A" & pasteLoop + 5 & ":DK" & pasteLoop + 5).Select

Selection.AutoFill Destination:=Range("A" & pasteLoop + 5 & ":DK" & pasteLoop + 6), Type:=xlFillDefault

Next pasteLoop

Application.Calculation = xlAutomatic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~
Jun 6 '07 #1
5 1456
DeMan
1,806 1GB
Hi liquid106,

Welcome to thscipts. This thread doesn't really fit the categories abvailable for forums (on the links from the blue bar at the top of the screen), so I will forward this on to the experts in "Miscellaneous Questions". Hopefully they can at least point you in the right direction!!
Jun 6 '07 #2
Hi liquid106,

Welcome to thscipts. This thread doesn't really fit the categories abvailable for forums (on the links from the blue bar at the top of the screen), so I will forward this on to the experts in "Miscellaneous Questions". Hopefully they can at least point you in the right direction!!

Sorry about that, wasn't sure where to put it!
Jun 7 '07 #3
Did anyone find an answer to this? I'm having a similar problem with one of my macros.

I had a macro that copied row 1 to 2, then 2 to 3, etc and it was taking way too long to complete. I then changed it to copy down all at once with no issues and much faster performance. That is until recently when I did a large data set with more rows and I received the "selection to large" error. The weird thing is that this macro does the same copy routine on several other tabs of my excel file with no problems. It only has a problem with this one tab. It doesn't matter if I re-order the macro to run the tabs in a different order, i.e. it always messes up on this tab.

This tab is slightly different from the others in that it is using an external reference to a *.dll that I made. Other than that it is an identical tab, copying the same sets of rows.

Any help would be appreciated.
Jun 26 '07 #4
bartonc
6,596 Expert 4TB
Did anyone find an answer to this? I'm having a similar problem with one of my macros.<snip>
This tab is slightly different from the others in that it is using an external reference to a *.dll that I made. Other than that it is an identical tab, copying the same sets of rows.
That's a great big "other than" in my view. I imagine that you tested your external function from outside the macro and it works (even on a large data set, as you describe). There are a lot of things to get right in order to make the external reference work and Excel is not a great tool.

Just my view,
Barton
Jun 27 '07 #5
Yes it is a great big "other than". I probably should have mentioned that this copy down macro (which has the error) has nothing to do with the external *.dll. All this macro does is copy the rows down. The source cells have only standard excel formulas in them. A co-worker suggested that maybe one of the formulas was extrodinarily complicated (bunch of nested if statements) so I removed that but with no luck.

The external *.dll is used, manually, much later (and in a completely different macro). All the *.dll does is grab a big matrix, do some calculations, and return the same size matrix back.

Thanks for the response!
Jul 5 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Roger | last post by:
I've got a filter form to select customers, products, etc and these are used in parameter queries, ie WHERE t_cuno Like !! the parameter queries, roll up to a crosstab query, that is used to...
12
by: elziko | last post by:
I'm using late binding (I must) to automate Excel. My code opens Excel after createing and poulating some sheets. My problem is that when the user finally decides to close Excel its process is...
9
by: cow3 | last post by:
Is there anyone who can help me with this: I have written a fairly complicated vb application of hydrological model that does a lot of number crunching. The model creates a set of object...
0
by: Rich Wallace | last post by:
Hello all, Looking for suggestions and tips if possible. I have an application running on a file server that utilizes the FileSystemWatcher to trap when any Excel files are saved by a user. I...
4
by: Peter | last post by:
Does anyone know a way to import excel data very fast? I have spreadsheet data that has to be processed, the spreadsheet has 256 columns and 20,000 rows of data. That's 5,120,000 cells. The...
11
by: Giggle Girl | last post by:
Hello Javascript enthusiasts! I need to lock a TABLE HEADER vertically, so when you scroll up/down, the content moves but the header is always visible, like you can do in Excel. It is for an...
10
by: Hendri Adriaens | last post by:
Hi, I'm trying to automate the creation of an excel file via COM. I copied my code below. I read many articles about how to release the COM objects that I create. The code below runs just fine...
10
by: afromanam | last post by:
Regards, Please help What I'm trying to do is this: (and I can't use reports since I must export to Excel) I export some queries to different tabs in an excel workbook I then loop through...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.