473,385 Members | 1,396 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,385 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 1455
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.