SOLVED

RECALCULATION & RANDOM NUMBERS

%3CLINGO-SUB%20id%3D%22lingo-sub-2367176%22%20slang%3D%22en-US%22%3ERECALCULATION%20%26amp%3B%20RANDOM%20NUMBERS%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2367176%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EI%20have%20created%20an%20Excel%20Workbook%2C%20with%20the%20objective%20of%20trying%20to%20simulate%20the%20queues%20on%20a%20Golf%20Course%2C%20depending%20on%20the%20gap%20between%20consecutive%20tee%20off%20times.%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3EWorksheet%201%20contains%20basic%20data%2C%20such%20as%20the%20par%20for%20each%20hole%2C%20the%20minimum%2C%20average%20and%20the%20maximum%20time%20likely%20to%20be%20spent%20playing%20each%20hole%2C%20etc%20etc%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3EWorksheet%202%20contains%2020%20sets%20of%20%E2%80%98random%20duration%20times%E2%80%99%20for%20playing%20each%20hole%2C%20generated%20from%20the%20parameters%20within%20Worksheet%201.%20For%20the%20statisticians%2C%20I%20use%20the%20probability%20density%20function%20of%20a%20Triangular%20Distribution%2C%20and%20the%20appropriate%20Excel%20formula%20%2F%20function%20to%20calculate%20these%20random%20values.%20Each%20of%20these%2020%20sets%20contains%20100%20%E2%80%98random%E2%80%99%20rounds%20of%20golf%20timings.%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3EWorksheet%203%20performs%20all%20of%20the%20Queue%20Calculation%20for%20a%20particular%20value%20of%20the%20parameter%20G%2C%20which%20is%20the%20gap%20between%20consecutive%20tee%20off%20times.%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3ESo%20I%20set%20G%3D10%2C%20and%20work%20out%20the%20Queue%20calculation.%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3EMy%20problem%20is%2C%20that%20if%20I%20now%20set%20G%3D8%20(say)%2C%20all%20of%20the%20%E2%80%98random%E2%80%99%20durations%20also%20get%20recalculated%20(all%2018x100x20%20of%20them).%20But%20I%20need%20to%20compare%20G%3D10%20with%20G%3D8%20using%26nbsp%3B%3C%2FSPAN%3E%3CU%3E%3CSTRONG%3Eexactly%3C%2FSTRONG%3E%3C%2FU%3E%3CSPAN%3E%26nbsp%3Bthe%20same%20set%20of%20%E2%80%98random%E2%80%99%20data%2C%20not%20a%20(somewhat)%20different%20set.%20(otherwise%20I%20might%20have%20introduced%20an%20unnecessary%20extra%20variable)%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3EIs%20there%20a%20way%20that%20I%20can%20set%20Worksheet%202%2C%20to%20only%20recalculate%20manually%2C%20whilst%20the%20remainder%20of%20the%20Workbook%2C%20recalculates%20automatically%3F%20If%20so%20how%3F%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3EOr%20can%20I%20set%20particular%20ranges%20in%20Worksheet%202%20to%20only%20recalculate%20manually%3F%20If%20so%2C%20how%3F%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3EOr%20is%20the%20another%20better%20solution%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2367176%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2368356%22%20slang%3D%22en-US%22%3ERe%3A%20RECALCULATION%20%26amp%3B%20RANDOM%20NUMBERS%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2368356%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20the%20thoughts.%3C%2FP%3E%3CP%3EI've%20'done'%20the%20%22copy%2C%20paste%20values%20solution%22%2C%20but%20since%20I%20have%2020%20sets%20of%20data%20it%20is%20a%20pain.%3C%2FP%3E%3CP%3EAm%20I%20correct%20in%20thinking%20there%20is%20no%20%22manual%20calculation%22%20facility%20for%20a%20specific%20sheet%20in%20a%20workbook%2C%20rather%20than%20the%20whole%20workbook%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2368358%22%20slang%3D%22en-US%22%3ERe%3A%20RECALCULATION%20%26amp%3B%20RANDOM%20NUMBERS%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2368358%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1054650%22%20target%3D%22_blank%22%3E%40DAHOWARDUK%3C%2FA%3E%26nbsp%3B%20%60%60Is%20there%20a%20way%20that%20I%20can%20set%20Worksheet%202%2C%20to%20only%20recalculate%20manually%2C%20whilst%20the%20remainder%20of%20the%20Workbook%2C%20recalculates%20automatically%3F%60%60%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes.%26nbsp%3B%20In%20a%20new%20%22normal%22%20module%20(not%20a%20worksheet%20object)%2C%20enter%20the%20following%20macros.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ESub%20disableCalc()%0AActiveSheet.EnableCalculation%20%3D%20False%0AMsgBox%20ActiveSheet.Name%20%26amp%3B%20%22%20enabled%3A%20%22%20%26amp%3B%20ActiveSheet.EnableCalculation%0AEnd%20Sub%0A%0ASub%20enableCalc()%0AActiveSheet.EnableCalculation%20%3D%20True%0AMsgBox%20ActiveSheet.Name%20%26amp%3B%20%22%20enabled%3A%20%22%20%26amp%3B%20ActiveSheet.EnableCalculation%0AEnd%20Sub%0A%0ASub%20calcStatus()%0AMsgBox%20ActiveSheet.Name%20%26amp%3B%20%22%20enabled%3A%20%22%20%26amp%3B%20ActiveSheet.EnableCalculation%0AEnd%20Sub%0A%0ASub%20recalcSheet()%0ADim%20oldcalc%20As%20Variant%0Aoldcalc%20%3D%20ActiveSheet.EnableCalculation%0AActiveSheet.EnableCalculation%20%3D%20False%0AActiveSheet.EnableCalculation%20%3D%20True%0AActiveSheet.EnableCalculation%20%3D%20oldcalc%0AMsgBox%20ActiveSheet.Name%20%26amp%3B%20%22%20enabled%3A%20%22%20%26amp%3B%20ActiveSheet.EnableCalculation%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20Excel%2C%20use%20alt%2Bf8%20to%20select%20and%20run%20the%20desired%20macro.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20enter%20the%20following%20Worksheet_Open%20event%20macro%20or%20add%20the%20statement.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPrivate%20Sub%20Workbook_Open()%0ASheet2.EnableCalculation%20%3D%20False%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENote%3A%26nbsp%3B%20You%20might%20need%20to%20change%20Sheet2%20to%20the%20object%20name%20(not%20the%20worksheet%20name)%20of%20the%20worksheet%20with%20the%20%22frozen%22%20random%20data.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20demonstrated%20in%20the%20attached%20Excel%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENote%3A%20Sheet1%20contains%20one%20formula%20(A6)%20that%20used%20RAND()%20directly.%26nbsp%3B%20This%20is%20for%20demonstration%20purposes%20only.%26nbsp%3B%20Normally%2C%20we%20would%20put%20all%20random%20data%20in%20a%20separate%20worksheet%2C%20as%20you%20indicated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2368252%22%20slang%3D%22en-US%22%3ERe%3A%20RECALCULATION%20%26amp%3B%20RANDOM%20NUMBERS%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2368252%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1054650%22%20target%3D%22_blank%22%3E%40DAHOWARDUK%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThese%20suggestions%20are%20just%20%22off%20the%20top%20of%20my%20head%22%20things%20I'd%20try%20were%20I%20in%20your%20shoes.%20My%20apologies%20if%20you've%20already%20tried%20them.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3EIf%20you're%20only%20doing%20this%20as%20a%20%22one-time%22%20affair%20(as%20opposed%20to%20daily%20from%20scratch)%2C%20you%20could%20just%20copy%20the%20full%20range%20of%20randomly%20calculated%20values%2C%20and%20then%20do%20a%20%22paste-special%22%20values%20only%20to%20a%20different%20area%2C%20and%20use%20those%20now%20static%20values%20in%20conjunction%20with%20your%20various%20values%20of%20G.%3C%2FLI%3E%3CLI%3EAnother%20possibility%3A%20have%20Worksheet%202%20be%20a%20separate%20workbook%20of%20its%20own%2C%20not%20in%20the%20same%20workbook%20as%20Sheets%201%20and%203.%20You%20can%20still%20use%20its%20values%2C%20but%20(I%20haven't%20verified%20this)%20I%20don't%20think%20they'd%20be%20recalculated%20when%20the%20workbook%20containing%20sheets%201%20and%203%20are%20recalculated.%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20those%20are%20my%20two%20thoughts.%20Let%20me%20know%20if%20they%20make%20sense%3B%20even%20more%2C%20if%20they%20work!%20%3CLI-EMOJI%20id%3D%22lia_winking-face%22%20title%3D%22%3Awinking_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I have created an Excel Workbook, with the objective of trying to simulate the queues on a Golf Course, depending on the gap between consecutive tee off times.

Worksheet 1 contains basic data, such as the par for each hole, the minimum, average and the maximum time likely to be spent playing each hole, etc etc

Worksheet 2 contains 20 sets of ‘random duration times’ for playing each hole, generated from the parameters within Worksheet 1. For the statisticians, I use the probability density function of a Triangular Distribution, and the appropriate Excel formula / function to calculate these random values. Each of these 20 sets contains 100 ‘random’ rounds of golf timings.

Worksheet 3 performs all of the Queue Calculation for a particular value of the parameter G, which is the gap between consecutive tee off times.

So I set G=10, and work out the Queue calculation.

My problem is, that if I now set G=8 (say), all of the ‘random’ durations also get recalculated (all 18x100x20 of them). But I need to compare G=10 with G=8 using exactly the same set of ‘random’ data, not a (somewhat) different set. (otherwise I might have introduced an unnecessary extra variable)

Is there a way that I can set Worksheet 2, to only recalculate manually, whilst the remainder of the Workbook, recalculates automatically? If so how?
Or can I set particular ranges in Worksheet 2 to only recalculate manually? If so, how?
Or is the another better solution?

3 Replies

@DAHOWARDUK 

 

These suggestions are just "off the top of my head" things I'd try were I in your shoes. My apologies if you've already tried them.

 

  1. If you're only doing this as a "one-time" affair (as opposed to daily from scratch), you could just copy the full range of randomly calculated values, and then do a "paste-special" values only to a different area, and use those now static values in conjunction with your various values of G.
  2. Another possibility: have Worksheet 2 be a separate workbook of its own, not in the same workbook as Sheets 1 and 3. You can still use its values, but (I haven't verified this) I don't think they'd be recalculated when the workbook containing sheets 1 and 3 are recalculated.

 

So those are my two thoughts. Let me know if they make sense; even more, if they work!

@mathetes 

Thanks for the thoughts.

I've 'done' the "copy, paste values solution", but since I have 20 sets of data it is a pain.

Am I correct in thinking there is no "manual calculation" facility for a specific sheet in a workbook, rather than the whole workbook?

best response confirmed by DAHOWARDUK (New Contributor)
Solution

@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.