Solved

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

Posted on 2014-02-14
4
1,238 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you how to use shortcut menus in the Access run-time environment.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

770 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