Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel macro stopping

Status
Not open for further replies.

filmstar

Computer
May 9, 2002
2
Hi
I have an excel sheet that performs calculations then i use a macro to copy and paste the results into another sheet. The macro then continues to call in new data from a source and the sheet re-calculates and copy and paste again. The sheet is around 10mb in size.
I have 2 issues. Firstly the macro just stops after a period, anything from 10 mins to 10 hours. Secondly the macro takes all the CPU available on my pc. I have included a delay between calling each action 1) calling in source data 2)re-calculating sheet 3) copy and paste. But even during these gaps the macro takes all the cpu. Can i write a better macro that frees up the cpu, i am thinking maybe this 100% cpu usage is stopping the macro?

Can anyone help?
Thanks
 
Replies continue below

Recommended for you

you say "continues to call in data from a source" - is this source an external seriel type of source? This could totally block the PC if you continueously request data from the seriel port i believe.

I dont know about the stopping - but win 95-98 me? is not very suited for real time data acc. application as far as i know (unix or the like should be better).

Best Regards

Morten
 
we use windows 2000. The data is from an external source, ie share prices from a data vendor.
 
Filmstar,

I don't think adding a timer will help, since in VBA the timer is executed synchronously.
You could try adding a "DoEvents" statement at strategic parts of the code. This tells the program to release the CPU for other tasks, and is needed if you have "tight" CPU intensive code.
 
filmstar:

I have a word program template that reads data from an excel program (just a spreadsheet with a TON of formulas). I also have a "read me" sheet that (in effect) just reads the data from the excel program. When I try to update the wordfile without the "read me" file open, it takes forever! It takes so long because word is continually reading values, recalculating the sheet and pasting values. With the "read me" sheet open, the update takes only seconds.

I don't know what would happen if you turned excel's "Auto calculate" off and then tried your macro. It may help speed the process (it may not be an option though, from what it sounds like...). You may also want to see if you can import all the external data into an array variable in VBA or even another excel spreadsheet and try to read it from there.

Hope this helps!

jproj
 
There are several ways to make your spreadsheet run faster.
For example, copying and pasting by "Range" instead of writing to cells by looping blocks, turning off screen updating by using Application.Screenupdating=False, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor