Share via

importing a .csv file without excel application recalculating vba

Anonymous
2012-02-07T18:02:01+00:00

Hi,

I am trying to import a .csv file using vba,  I have stated at the beginning on the line of code  xlcalculationmanual however any time i run a macro to import the data held in the file the workbook recalculates.

I cannot write a macro into the .csv file to turn off the calculations as the file is overwritten everyday.

any ideas?

Thanks

Tom

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Andreas Killer 144.1K Reputation points Volunteer Moderator
2012-02-08T11:05:47+00:00

The question is how did to you import the CSV data and what else did you do.

If you set the Calculation to manual, the workbook did not recalculate, even if you change a cell, that's a fact.

Example:

Sub Test()

  Dim SaveCalculation As XlCalculation

  SaveCalculation = Application.Calculation

  Application.Calculation = xlCalculationManual

  Range("A1").Formula = "=A2+1"

  Range("A2") = 1

  Application.Calculation = SaveCalculation

End Sub

Copy this sub into a normal module in a new file, press F8 to execute it line by line and look into the sheet after you execute a line what's happen.

You'll see that a formula is calculated if you enter (or change it), even if the calculation is in manual mode. That means you can not switch the calcultion TOTALLY OFF!

If you enter the value in A2, the formula in A1 is not recalculated as expected.

But the formula is recalculated if you set the Calculation property to an automatic mode!

Andreas.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful