Windows 7, 64-bit PC... Slow macro (VBA)

Will from London

Board Regular
Joined
Oct 14, 2004
Messages
220
Hi

My company has just changed my PC from:
Windows 7 (32 bit), Office 2010 with 4GB of RAM (Intel i3-4160T 3.1GHz) to
Windows 7 (64 bit), Office 2013 (32 bit) with 8GB of RAM (Intel i3-2120 3.3GHz)

A VBA macro took about 7 minutes on my old PC but after 2 hours of running on the new PC it had only processed about half the data. The code essentially loops through each line of 7 CSV files (ranging from 10k to 200k lines), does a little bit of manipulation and then writes the line to 7 new CSVs. Even on my even older PCs it took a few minutes not hours.

I've seen that VBA code on 64-bit Excel needs to be slightly different (declared Long's etc) but I've still got 32-bit Office so does anyone have any ideas?

Thanks in advance

Will
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Can you post some (or all) of your code so we can have an idea of what exactly is going on.
There are probably a bunch of things you can do to speed things up, but without knowing what is going on currently, it is impossible to offer specific recommendations.

The only systemic issues I am aware of (not necessarily the only one there is) involves Protecting/Unprotecting sheets.
You could always try turning screenupdating off before the macro and back on after the macro and see if that helps.
 
Last edited:
Upvote 0
Thanks for your reply. The issue is more that the 64-bit PC is running at about 1/34th of the speed of the 32-bit one using exactly the same data, code, drive etc. I retested on a colleague's 32-bit and it took under 7 minutes. That sort of time is fine. 2-4 hours is not.

I can't post the code due to security rules but anyway, the code does the following (with explicit declarations):
1. Open path & existing filename For Input As #1
2. Open path & new filename For Output As #2 (after checking that new filename did not already exist)
3. Line Input #1, tempStr
4. Uses "Replace" to change some of the tempStr text
5. Print #2, tempStr
6. Application.StatusBar = j
7. j = j + 1
8. Loops through 3-8 using "Do Until EOF(1) = True"
9. Close #2
10. Close #1
11. Application.StatusBar = False

It doesn't use the Excel sheets themselves to do any processing, so switching screenupdating off is unlikely to help (pathname & filename etc are in cells for inputs). Calculation is manual and there are no other Excel files open.

Regards

Will
 
Upvote 0
There's very little in your description of your macro that sounds like it can be sped up.

When you run a 32-bit program on a 64-bit version of Windows, it has to run under something called WoW64 (Windows on Windows). Here's a description:

https://en.wikipedia.org/wiki/WoW64

I can't say for sure, but often when you have another layer of interpreter between the OS and your program, that can slow things down. You may want to see if you can get a 64-bit version of Excel to experiment with.

Lacking that, your macro sounds pretty basic. Maybe you can try rewriting it in Java or Python. Both can be obtained for free from the Internet, and aren't too hard to learn for someone with basic programming experience.

Hope this helps.
 
Upvote 0
Thanks for the reply and link.

I will be given the opportunity to experiment on a 64-bit version of Office soon.

Also, I've not tested this Excel file on another 64-bit machine to deal with the possibility that my machine is the problem (but I've not noticed anything else be orders of magnitude slower). I've also not tested any of my other, more complicated, macros.
 
Upvote 0

Forum statistics

Threads
1,215,231
Messages
6,123,754
Members
449,119
Latest member
moudenourd

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