how to Speed Up the VBA Macros

前端 未结 7 1666
陌清茗
陌清茗 2021-01-24 06:06

I am Generating a New Sheets using macros. For a New Sheet generation , Data is retrieved from more than 4 MS Access DB. Each DB had minimum 200 field. My Macro code includes

相关标签:
7条回答
  • 2021-01-24 06:31

    You can try the usual vba optimization methods of setting calculation to manual and disabling ScreenUpdating.

    Dim calc As XlCalculation
    calc = Application.Calculation
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    
    Application.ScreenUpdating = True
    Application.Calculation = calc
    

    Put your code or function call between Application.Calculation = xlCalculationManual and Application.ScreenUpdating = True.

    This is from my previous Post

    Note: I coundn't find info weather or not you run the code from within Access or Excel. If you create the Excel Workbook from Access you probably have some code like this:

    Dim xlApp As Excel.Application
    Set xlApp = new Excel.Application
    

    In this case you would have to change Application in the code above to xlApp. For example:

    xlApp.Calculation = xlCalculationManual
    
    0 讨论(0)
提交回复
热议问题