Forum Discussion
RECALCULATION & RANDOM NUMBERS
- May 19, 2021
DAHOWARDUK ``Is there a way that I can set Worksheet 2, to only recalculate manually, whilst the remainder of the Workbook, recalculates automatically?``
Yes. In a new "normal" module (not a worksheet object), enter the following macros.
Sub disableCalc() ActiveSheet.EnableCalculation = False MsgBox ActiveSheet.Name & " enabled: " & ActiveSheet.EnableCalculation End Sub Sub enableCalc() ActiveSheet.EnableCalculation = True MsgBox ActiveSheet.Name & " enabled: " & ActiveSheet.EnableCalculation End Sub Sub calcStatus() MsgBox ActiveSheet.Name & " enabled: " & ActiveSheet.EnableCalculation End Sub Sub recalcSheet() Dim oldcalc As Variant oldcalc = ActiveSheet.EnableCalculation ActiveSheet.EnableCalculation = False ActiveSheet.EnableCalculation = True ActiveSheet.EnableCalculation = oldcalc MsgBox ActiveSheet.Name & " enabled: " & ActiveSheet.EnableCalculation End SubIn Excel, use alt+f8 to select and run the desired macro.
Also, enter the following Worksheet_Open event macro or add the statement.
Private Sub Workbook_Open() Sheet2.EnableCalculation = False End SubNote: You might need to change Sheet2 to the object name (not the worksheet name) of the worksheet with the "frozen" random data.
This is demonstrated in the attached Excel file.
Note: Sheet1 contains one formula (A6) that used RAND() directly. This is for demonstration purposes only. Normally, we would put all random data in a separate worksheet, as you indicated.
DAHOWARDUK ``Is there a way that I can set Worksheet 2, to only recalculate manually, whilst the remainder of the Workbook, recalculates automatically?``
Yes. In a new "normal" module (not a worksheet object), enter the following macros.
Sub disableCalc()
ActiveSheet.EnableCalculation = False
MsgBox ActiveSheet.Name & " enabled: " & ActiveSheet.EnableCalculation
End Sub
Sub enableCalc()
ActiveSheet.EnableCalculation = True
MsgBox ActiveSheet.Name & " enabled: " & ActiveSheet.EnableCalculation
End Sub
Sub calcStatus()
MsgBox ActiveSheet.Name & " enabled: " & ActiveSheet.EnableCalculation
End Sub
Sub recalcSheet()
Dim oldcalc As Variant
oldcalc = ActiveSheet.EnableCalculation
ActiveSheet.EnableCalculation = False
ActiveSheet.EnableCalculation = True
ActiveSheet.EnableCalculation = oldcalc
MsgBox ActiveSheet.Name & " enabled: " & ActiveSheet.EnableCalculation
End Sub
In Excel, use alt+f8 to select and run the desired macro.
Also, enter the following Worksheet_Open event macro or add the statement.
Private Sub Workbook_Open()
Sheet2.EnableCalculation = False
End Sub
Note: You might need to change Sheet2 to the object name (not the worksheet name) of the worksheet with the "frozen" random data.
This is demonstrated in the attached Excel file.
Note: Sheet1 contains one formula (A6) that used RAND() directly. This is for demonstration purposes only. Normally, we would put all random data in a separate worksheet, as you indicated.