Share via

What is wrong with this coding?

Anonymous
2022-08-08T14:53:59+00:00

Referring to following coding, it hangs for not responding for long period of time.

I would like to know on what wrong it is and how to solve it.

ActiveSheet.EnableCalculation = True ' in case it was False
With Application
.Calculation = xlCalculationManual
.CalculateBeforeSave = False
.ScreenUpdating = True
End With

Does anyone have any suggestions?
Thanks in advance

Microsoft 365 and Office | Excel | Other | 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

5 answers

Sort by: Most helpful
  1. Anonymous
    2022-08-09T10:37:54+00:00

    I can only monitor the running status, process is hanging here as shown below.

    I also place a mark on function, which require a lot of calculation, but it does not goes and stop on those function yet during hanging period.

    Is there any approach to determine where could go wrong?

    Do you have any suggestions?

    Thank you very much for any suggestions (^v^)

    Case 1

    Some coding ...

    ActiveSheet.EnableCalculation = True ' in case it was False
    With Application
    .Calculation = xlCalculationManual ' Not responding for calculation
    .CalculateBeforeSave = False
    .ScreenUpdating = True
    End With

    Was this answer helpful?

    0 comments No comments
  2. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2022-08-09T07:03:44+00:00

    I test above 2 cases with the same coding, there is "not responding for calculation only for case 1, not for case 2.

    If the code is the same, why should it be this code?

    Logical, isn't it?

    Andreas.

    Was this answer helpful?

    0 comments No comments
  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. Anonymous
    2022-08-08T16:05:09+00:00

    With removing coding, when I perform xlCalculationManual, it still take a long time,

    [Removed] ActiveSheet.EnableCalculation = True ' in case it was False
    With Application
    .Calculation = xlCalculationManual
    .CalculateBeforeSave = False
    .ScreenUpdating = True
    End With

    Case 1

    Some coding ...

    ActiveSheet.EnableCalculation = True ' in case it was False
    With Application
    .Calculation = xlCalculationManual ' Not responding for calculation
    .CalculateBeforeSave = False
    .ScreenUpdating = True
    End With

    Case 2

    ActiveSheet.EnableCalculation = True ' in case it was False
    With Application
    .Calculation = xlCalculationManual ' No problem at all, when I run it independently.
    .CalculateBeforeSave = False
    .ScreenUpdating = True
    End With

    I test above 2 cases with the same coding, there is "not responding for calculation only for case 1, not for case 2.

    Do you have any suggestions on what else could go wrong?

    Thank you very much for any suggestions (^v^)

    Was this answer helpful?

    0 comments No comments
  5. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2022-08-08T15:16:50+00:00

    As you can read here https://docs.microsoft.com/en-us/office/vba/api/excel.worksheet.enablecalculation

    When you change the value from False to True, Excel recalculates the worksheet.

    Excel calculates before you set

    Application.Calculation = xlCalculationManual

    and therefore it needs some time to perform (i guess a lot) of calculations, conditional formattings, etc.

    Andreas.

    Was this answer helpful?

    0 comments No comments