closing/reopening fixes problem of macro starting to insert all zeros; memory problem?

gte647i

New Member
Joined
Jun 9, 2008
Messages
6
I have written a macro that calls a third party software engine called EPANET through a provided DLL library. I run this engine and then access certain outputs via some provided functions, all inside VB. Then I write these values to a spreadsheet.

Everything works fine except that, after running the macro through several hundred iterations of this and pasting to several hundred rows in my spreadsheet that contains the macro, the macro starts inserting all zeros. If I close and reopen the file, then start back at the first place the zeros started appearing, the macro works fine and inserts the correct values. But eventually this will happen again.

Is this a memory issue? When I tried to run the macro on all 4400+ rows, my whole computer froze and I had to turn the power off and restart. So then I started doing smaller chunks, which avoided the locking up. But, once the zeros start appearing, even doing 10 rows at a time does not help. It appears as if it reaches some limit where it will no longer insert any values into the spreadsheet other than zeros until I close and reopen the workbook.

The code is nothing special except for the EPANET part. I just access some parameters using the EPANET VB functions. Then I do a simple assignment to the cells using the "...Cells(i,j).Value = mynumber" command, which I use all the time.

I've coded in VB quite a bit, but I've always done spreadsheet manipulations and don't know anything about handling memory explicitly.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Apologies for forgetting my system info:
-Windows XP, SP2, 1GB RAM
-VB inside Excel 2007
-file containing macro and where data is being dumped is about 5 MB
-macro is a "simple" sub procedure in a module
-third party EPANET engine is a separate module with constants and functions based on a .DLL file provided with EPANET files to interface with VB
 
Upvote 0

Forum statistics

Threads
1,221,590
Messages
6,160,668
Members
451,662
Latest member
reelspike

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top