Solved

Large Excel spreadsheet calculates when using VBA code to open a csv file

Posted on 2014-02-14
4
1,229 Views
Last Modified: 2014-02-20
Environment: Windows 8.1, Excel 2013, 64 bit, 6 gigs RAM

I have a large (300 Mg) workbook which uses VBA code to open and load data from .csv files to various sheets.

When the code to open the .csv file executes, the main workbook goes into calculation mode (even though calculation is set to manual both in the excel formulas tab and in the VBA code)
This calculation can take up to 30 minutes each time a .csv file is opened ( about 12 of them).

This behavior just started, as previously over the last week of development, the .csv file would open instantly, The VBA code would copy and paste the data of interest into the appropriate sheet instantaneously.

I have used both Excel 2010 and 2013 64 bit to open the workbook and execute the code with the same results.  

I tried upgrading from windows 8.0 to 8.1 and still have the same results.

Please provide some specific steps which will stop the calculation behavior until the VBA module executes a range calculate or an application calculate instruction.

Thanks
0
Comment
Question by:wheat01
  • 2
4 Comments
 
LVL 19

Expert Comment

by:regmigrant
ID: 39860880
difficult to debug without a copy of the code but I would try adding the following before each file open:-

if application.calculation <>xlcalculationmanual Then
                  debug.print "not manual"& <some way of identifying where the code is at>
                  application.calculation = xlcalculationManual
          Endif

Open in new window


if the problem persists after this post back but at least it should prove the manual calc is in place before the file is read.
0
 
LVL 33

Expert Comment

by:Norie
ID: 39860890
Have you tried importing the data from the CSV file via Data>From Text?

That might stop the calculation that happens when you open a file.
0
 

Accepted Solution

by:
wheat01 earned 0 total points
ID: 39861696
Neither comment resolved the issue or lead to the resolution.  The workbook calculating in spite of having the calculation method set to manual for the workbook and issuing several application.calculation = xlCalculationManual statements in the code was resolved as follows:

Count = ThisWorkbook.Sheets.Count

For i = 1 To Count
  Sheets(i).EnableCalculation = False
Next

However, thanks for your input.
0
 

Author Closing Comment

by:wheat01
ID: 39872903
Reason is contained in my post. Thanks.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now