Home
Crystal Ball Developer`s Guide Release 11.1.2.3.500
Contents
1. Named Constant Value Value Description Value1 Optional Value2 Optional cbRptTrendChart 2 Includes all open trend charts Boolean True includes the Integer 1 to 200 in the report at a specified chart False does not defines the percent scale scale of the chart cbRptSensitivChart 3 Includes all open sensitivity Boolean True includes the Integer 1 to 200 charts in the report at a chart False does not defines the percent specified scale scale of the chart cbRptForeSummaries 4 Includes summary information Boolean True includesthe n a about the included forecasts summaries False does not cbRptForeStatistics 5 Includes the statistics table for Boolean True includes the n a each included forecast statistics False does not cbRptForeCharts 6 Includes the frequency chartfor Boolean True includes the Integer 1 to 200 each included forecast at a chart False does not defines the percent specified scale scale of the chart cbRptForePercentiles 7 Includes the percentile Boolean True includes the Integer See Table 34 statistics for each included percentiles False does not forecast cbRptChooseFore 9 enables you to clear add and Integer See table Table 35 n a set the list of forecasts to following include in the report cbRptAssumParam 10 Includes the distribution Boolean True includes the n a parameters for each included parameters False does not assumption
2. Crystal Ball Macro Calls In This Chapter MOI it scans teh thc o aso A CN a A A Dura USED loa aL 50 5 NGOINBOU O nelle 50 LES MIT PME Mmm 51 CD AtentOn Macro eB IEITOE sa Led eek Cer eee a LE UE CUR CU ER d d aed 51 HET MuR M T 52 COSINA AA 53 COAUTOR Tr Q 53 Oss Ea AMS este ee Ten e ond tao te P CMT NN 54 QT HUT HL Pee TTE O A 55 CABORD M 63 CR BOOT ir npe M 63 CR adore Pe MAN cxicainnas pica pc adas Dea i dide m bdb Ulud ainda deg ans 67 CD B aad ks int cect Poit A EU YO ROC EE Ga oA 67 rfe S n 68 operc a a IEEE 69 KDE TES ns dala uno aa Gael aspe AR caa pU tense NES aon rd UR Ka Er RR 71 LEM M Pe UE 72 oT ip E 714 CONAM ac da a al pi 15 BNET IRI T M RISS TT a TP 78 A A rn T9 AE A ani eens Om ae Hee ESO Wie EMI Pla HC T9 EOI H EER 80 ofc Sr o ETT 81 ASE TBI pias cod ac tiU QU pda epi pra ddp s wince qs 82 CEDE DE cocer uis type PORE A EDI nce ied RIS M nein Rare p qus Mdb d Ue kpaue ROSEO DU ON 82 HER MUS IRI sem T 83 GOODS cisco co aM M dE CMM d M iu M Edad E 84 COCOS isa pai 85 CACO MoN ssl A il Ce Era edo Lea d ceed 86 COORD Me TET 86 LSA ONG BRITE pe EEUU 88 47 48 CB CreateChart B d CB CreateRpt K
3. Index Parameter Named Constant Value cbExtPredictorResultsResiduals Index Parameter Value Parameter Index Value Values to Use Description 23 True or False True includes residuals data in extracted results False does not include residuals data For information on residuals data see the Oracle Crystal Ball Predictor User s Guide cbExtPredictorMethodsErrors 24 True or False True includes methods error data in extracted results False does not include methods error data cbExtPredictorMethodsStatistics 25 True or False True includes methods statistics data in extracted results False does not include methods statistics data cbExtPredictorMethodsParameters 26 True or False True includes methods parameters data in extracted results False does not include methods parameters data cbExtPredictorMethodsRanking 27 True or False True includes methods ranking data in extracted results False does not include methods ranking data cbExtChartBinsUseEntireRange 28 True or False True uses the entire chart range including extreme values that are not displayed False uses only the displayed chart range The following values are used with Index cbExtDataType to specify the type of Crystal Ball data to extract Table 70 Value Parameter Values that Support Index Constant cbExtDataType Named Constant Value Index Value Description cbDatForeValues 1 Extracts forecast and assumpti
4. For Index 8 cbTwoDMSDOption Integer Integer from 2 to 250 inclusive n a Returned to indicate the maximum number of uncertainty simulations to display in the output report and overlay chart Table 148 CB GetTwoDSimulationOption Value2 Parameter Optional Variant VBA Data Related Value Value or Named Constant Type Index Description For Index 6 True or False Boolean n a Indicates whether the specified va1ue1 cbTwoDOutputOption Integer constant is active or not if set to True the specified items are included in the output report For Value1 A string containing a String n a Returns custom percentile values specified for cbTwoDPercentCustom Microsoft Excel range to CB TwoDSimulationND hold desired percentile values 186 Crystal Ball Macro Calls CB GetTwoDSimulationOption Example 1 This example returns a constant that indicates the current forecast display option cbTwoDShowDefineFore cbTwoDShowTargetFore or cbTwoDHideFore CB GetTwoDSimulationOption cbTwoDForeOption CB GetTwoDSimulationOption Example 2 This example returns a set of custom percentile values The returned values are placed in the specified range in this case F20 H20 CB GetTwoDSimulationOption cbTwoDPercent cbTwoDPercentCustom F20 H20 CB GetTwoDSimulationOption Related Calls Name Description CB TwoDSimulation Launches the 2DSimulation tool CB TwoDSimulationND Runs the 2DSimulation tool
5. oer A rs bold m 163 CB GetCorrelationByRef Example 444 e eee 164 CB GetCorrelationByRef Related Calls cria rara rr ee L64 CAOS cs cee oon RTEEREAqERECKO FETA VES Yd Qe EF A aE h 164 CBGetDataAnalysisOption Example 122g dua ckru paaxkerusaacugudue 166 CODO pon Example ls aces be Wud A wr a AREE REA Ed OS 166 Contents ix x Contents CB GetDataAnalysisOption Related Calls aces bas Me ed 166 DB DUBII Sb DNE i444 aea REOR setas esa ONE CB GetDecisionTableOption Example N ELE T ee ee Ree addu 167 CB GetDecisionTableOption Related Calls ebeyeeehawes ee 168 du fecal A m 168 CB GetDecYar Be iaa ke DOR PAURA aa A 169 CBGelDecVar Related Calls ar RRA AAA RA AAA 169 CB GetExcel2007ForegroundMode ass 169 CB GetixceliDOTPoreeround Mode Example ess cesses coud ara sawed racha dnd 170 CB GetExcel2007ForegroundMode Related Calls 5 222222224e9 esa 170 CB GetFitFilter er ebai gees nba er ew Raps aa 170 Cre Exetel dro EA ERE RAR ARA EY dE 171 CB GetFitFilter Related Calls EIV EA TIL TET 171 CHBGHPRPAI soria A d PEG doa Ebo odo car dub oaa e AR CR ee di 171 Cee A EO IE ca rs ss pi pde Lee CB GetFitParm Related Calls erase PLI VR ERICH ERE 172 CHAMPS renace alar 173 CB GetFore Example T TEE mews ws oru I Tor oe 174 CE bdFote Reed Calle a bcc dvd O DEO CBGetForeData d
6. CB RuntimeMode on page 209 the Crystal Ball menus and toolbar or ribbon in Microsoft Excel 2007 or later are hidden You can give users the ability to run reset and single step through simulations by creating your own user interface controls with Visual Basic or VBA that call appropriate Crystal Ball Developer Kit subroutines and functions You can also use the Crystal Ball Developer Kit macros to create controls that extract data create charts and reports and more When simulations run in Runtime mode the Crystal Ball Control Panel is switched offby default However you can use Visual Basic or VBA to switch it on again using appropriate calls to CB Simulation or CB RunPrefsND Even if the Control Panel dialog is displayed though the Run Analyze and Help menus are hidden Users can access Predictor if you use calls from the Predictor Developer Kit to access Predictor features See Appendix B Using the Predictor Developer Kit Runtime Example Workbook Crystal Ball includes Runtime Example xls a very basic application written in VBA using the Crystal Ball Developer Kit to show how UI controls in this case buttons can be created to Introduction 271 operate a Crystal Ball Runtime application You can open this example in the Examples folder under the folder where Crystal Ball is installed Delivering Crystal Ball Runtime Applications An appropriate Crystal Ball license must be purchased for each person who will
7. Table 60 CB DeleteChart Parameters and Constants VBA Data Parameter Type Value Description SimChart Type Integer cbChtOverlay 1 cbChtScatter Specifies the type of chart you are deleting overlay scatter 2 cbChtSensitiv 3 sensitivity or trend For named constant and index values cbChtTrend 4 see the Value column Chart ID Optional String Chart ID The chart ID returned by CB EnumChart Table 62 entered directly or using CB EnumChart CB DeleteChart Example This example deletes the overlay chart trend chart and sensitivity chart specified with CB EnumChart CB CheckData CB DeleteChart cbChtOverlay CB EnumChart cbChtOverlay CB DeleteChart cbChtTrend CB EnumChart cbCht Trend CB DeleteChart cbChtSensitiv CB EnumChart cbChtSensitiv CB DeleteChart Related Calls Name Description CB CreateChart Creates a new chart of the specified type with the optional name if specified CB EnumChart Returns the chart ID of the next chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB DeleteChart 125 CB EnumAssum This function enumerates assumption cells for all open workbooks This command is useful for determining what assumptions have been defined for the open workbooks You can then call CB GetAssum for each assumption to retrieve specific information for example distribution type and parameters Table 61 CB EnumAssum Returne
8. Used With Specified Values of Index For Index 7 cbRunSamplingMethod Boolean Value True or False OR cbSamLatinCube True or cbSamMonteCarlo False Description True uses Latin Hypercube False uses Monte Carlo For Index 8 coRunSampleSize Integer A whole number between 10 and 5000 Sets the sample size for Latin Hypercube sampling For Index 10 cbRunCorrelationsOff Boolean True or False True turns off correlations False turns on correlations For Index 26 cbRunMinimizeHost Boolean True or False True minimizes Microsoft Excel during simulations False does not For Index 27 coRunMinimizeSheets Boolean True or False False minimizes worksheets during simulations True does not For Index 28 cbRunHideForecasts Boolean True or False True suppresses forecast and all other chart windows during simulations False does not For Index 29 cbRunMode Integer cbRunExtremeSpeed 1 cbRunNormalSpeed 2 cbRunDemoSpeed 3 Sets Crystal Ball to run in Extreme speed if available Normal speed or Demo speed depending on the named constant or index value listed in the Value column For Index 31 cbRunRandomSeed Long Any positive whole number Sets the seed value for using the same random sequence of numbers For Index 40 cbRunPrecisionControl Boolean True or False True uses precision control to stop the simulation False uses the
9. CB CopyTrend This call copies the selected trend chart to the clipboard If more than one chart is found but one is not selected a chooser dialog appears CB CopyTrend Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next trend chart in the workbook and then copies it CB Simulation 1000 CB CheckData CB SelectChart cbChtTrend CB EnumChart cbCht Trend CB CopyTrend CB CopyTrend Related Calls Name Description CB CloseTrend Closes the selected trend chart CB EnumChart Returns the unique name of the next chart of the specified type CB OpenTrend Opens the selected trend chart CB SelectChart Selects the chart with the specified chart ID CB CorrelateND This function defines or updates a correlation coefficient between the assumptions corresponding to two selected cells Note Starting in release 11 1 2 3 000 this call returns CorrMatrixErrorAlreadyCorrelatedifone or both assumptions are already included in a linked matrix If cross workbook cell references are attempted CorrRefAct iveWorkbook is returned Table 28 CB CorrelateND Parameters Parameter VBA Data Type Value Description Coefficient Variant A number between 1 0 and 1 Sets the correlation coefficient between two selected 0 assumptions 86 Crystal Ball Macro Calls Parameter VBA Data Type Value Description SecondAsm Microsoft Excel A si
10. CB CreateRptND 97 Table 37 For Index cbRptChartType Value1 Values Optional Integer Named Constant Value Index Value Description cbChtColored 1 Makes all charts colored Crystal Ball format cbChtExcel 2 Makes all charts Microsoft Excel format Note cbChtBW 0 was removed as an index to this parameter With Index set to cbRptSummary you can specify what to include in the summary see Table 38 Table 38 For Index cbRptSummary Value2 Values Optional Integer Named Constant Value Index Value Description cbRptSummaryTitle 1 Includes the report title cbRptSummaryDate 2 Includes the date cbRptRunPreferences 3 Includes run preferences for the simulation cbRptRunStatistics 4 Includes run statistics for the simulation With Index set to cbRptChooseDecVar you can specify which decision variables to include in a report see Table 39 Table 39 Index cbRptChooseDecVar Value1 Values Optional Integer Named Constant Value Index Value Description cbChdAll 1 Includes all decision variables cbChdChosen 2 Includes chosen decision variables Include a statement with this constant after added decision variables cbChdAdd 3 Adds the decision variable in the selected cell to the list of chosen decision variables cbChdClearList 4 Clears the list of chosen decision variables With Index set to cbRptChooseOverlay cbRptChooseTrend or cbRptChooseSensitivity you can
11. Decisioneering CB CBCOMDevkKt Predictor Namespace ElCollapse All CB Com Devkit Types 4 Language Filter C Name MRWrapper Decisioneering CB CBCOMDevKit Namespace Crystal Ball COM and NET Development Kit Namespace All Types Classes e Description MR Command vrapper Use in using statements to insure MR status tracked and set into command processor for all COM visible calls for DevKit integration The Index and Search tabs are helpful for locating information about a specific class For example if you click the Search tab type Constraint and then click List Topics you can select one of the listed topics in the navigation pane to display it in the content pane See Figure 3 following for an example of the Constraint Properties topic for OptQuest You can also review lists and descriptions of methods the classes themselves and other important development information Figure 3 CB Com Devkit chm Opened to the Constraint Properties Topic for OptQuest E CB Com Devkit gt 0 A A lt a Hide Locate Back Forward Stop Refresh Home a Decisioneering CB CBCOMDevKit Optimization Namespace 4 El BooleanOption Enumeration E a e ConEnumerator Class E QQ Constraint Class UENIT Constraint Type Property E Equation Property E e DecEnumerator Class E e Decision Class B DecVarValue Type Enumeration E Q amp VarEnumerator Interface E Objective Class E Q amp ObjEnumerator Class E
12. Table 134 CB GetForeStat Returned Data Type Returned Value Returned Data Type The specified statistic for the forecast Variant Table 135 CB GetForeStat Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 In a Points to the forecast cell for which you want the statistic worksheet B3 CB GetForeStat 177 Parameter VBA Data Type Index Integer Value Description See Table 136 Calculates the specified statistic for the forecast in the specified cell using the values listed in Table 136 Use the following Index named constant and index values Table 136 to return forecast statistics for the selected cell Table 136 CB GetForeStat Index Parameter Values Required Integer Named Constant Value Index Value Description cbFstTrials 1 Returns the number of trials cbFstMean 2 Returns the mean cbFstMedian 3 Returns the median cbFstMode 4 Returns the mode cbFstStdDev 5 Returns the standard deviation cbFstVariance 6 Returns the variance cbFstSkewness T Returns the skewness cbFstKurtosis 8 Returns the kurtosis cbFstCV 9 Returns the coefficient of variation cbFstRangeMin 10 Returns the range minimum cbFstRangeMax 11 Returns the range maximum cbFstRangeWidth 12 Returns the range width cbFstStdError 13 Returns the standard error cbFstBaseCase 14 Returns the
13. Table 64 CB EnumCorrelation Returned Data Type Returned Value Returned Data Type The current count of correlations left in the enumeration including the correlation returned by this call Variant Note For best results call CB CheckData once at the beginning of an enumeration to reset the sequence of correlated assumptions You should also call CB CheckData each time you add or delete data or perform other actions that restructure the worksheet Use CB CheckData or CB CheckDataND with CB MacroResultDetail to check for errors For more information see the descriptions of those calls If correlations are inconsistent CB CheckDataND returns CorrInconsistent CB EnumCorrelation still enumerates existing correlations in that case 128 Crystal Ball Macro Calls If the returned string is 0 all correlated assumptions have been enumerated You can only call this function from a subroutine or another function You cannot call this function from a worksheet Table 65 CB EnumCorrelation Parameters VBA Data Parameter Type Description Assuml String Represents the first assumption in a pair of correlated assumptions by reference returned as the absolute cell reference of the next correlated assumption in the format workbook sheet A 1 Assum2 String Represents the second assumption in a pair of correlated assumptions by reference returned as the absolute cell reference of the next correlated assumption in th
14. on page 88 Intercorrelates assumptions to create a correlation matrix CB CreateChart on page 90 Creates a new chart of the specified type with the optional name if specified CB CreateRpt on page 91 Creates a report from the current simulation and restored results optimization with an appropriate license or time series forecast using a dialog CB CreateRptND on page 92 Sets report preferences and creates a report from the current simulation and restored results optimization with an appropriate license or time series forecast without a dialog CB DataAnalysis on page 101 Launches the Data Analysis tool CB DataAnalysisND on page 102 Runs the Data Analysis tool without displaying dialogs CB DecisionTable on page 106 Launches the Decision Table tool CB DecisionTableND on page 106 Runs the Decision Table tool without displaying dialogs CB DefineAltParms on page 109 Creates or changes an alternate parameter set CB DefineAssum on page 112 Defines or changes assumptions in selected cells with a dialog CB DefineAssumND on page 113 Defines or changes assumptions in selected cells without a dialog CB DefineAssumFromForeND on page 117 Defines an assumption from a specified forecast without using a dialog CB DefineDecVar on page 119 Defines or changes a decision variable in a selected cell using
15. uas TOR TET M abe ba TET 150 CAGAS Example edad la cxx dE CB GetAssum Example 2 Habra wae ea ak eases Tr CB GetAssum Related Calls cc Rer RE REV seen Views de ave 152 CB GetAssumPercent dd Read dd ads dd bisa du 152 CB GetAssumPercent Example pec pP 153 GB GetAssumPerceni Exubple 3 copar 153 CB GetAssumPercent Related Calls 25 du EE See e s 158 EIA iia IA AAA AAA A E Edd d 154 CAGAS D adri RAS a AMD CD Os Aust Exaniple 2 ir A AN AA A A R A IA 155 e MAA A PU As A pp 155 Ch Ge batch Opler Example I 2aequdacsheesuacpeqdetaer epepRaea qug s 158 CB GetBatchFitOption Example 2 or er ver TO 158 CB GeatBatchFtOphion Related Calle ocio riadas rss L58 at ARA TE MN CB GetBootstrapOption Example Diuisarss Poo M dd 160 e a 2 4 azuse ad qi auper irnia ee koe does 100 CB OsBooteiripOpien Related Calg cr AREE ratiti 160 CB GeiCBAutoLoad 5 22222 sa Seen eee eT TT ee Te eee E EE ee 160 CB GetCBAutoLoad Example rus abe sees ees bud lt 161 CR GetCBAwtoLoad Related Calls 222254 iria s 161 CEGE eray sais oe nad akkas eT 161 CB GetCertainty Example 1 ead T M or re 162 COUNTERS cos sra DO a Related Calls AAA 162 CB GetCorrelation 294625202084 otesatsosce 162 CB GetCorrelation Example Pres stus T aus er TS es lt 163 CB outorsdddos Related Calle uisus AA ks 163 CB GetCorrelationByRef
16. 32 Putting Custom Applications into Runtime Mode 0 0 0 eee eee eee 32 Alphabetic List of Crystal Ball Morro Calls corra rara RA A tienes Spreadsheet Functions For Use in Microsoft Excel Models i244 wes 38 Opa and Close COSTRA aaa qoi uide a eR UR es oe pees ee ows 39 Bons Dp and Rani A AODE uu osaa arde bare EEEREN EPRE e pred 39 Controlling Crystal Ball Chart Windows c useazactuasscdetaechbud eder pas 41 Managing Charts TT Sees ees bes aus aw bud aw 41 Handing Crystal Dal Beull duke ua be sd n setti and Getting Prefetetites 5 occnce cv arene saa dese Guar des pa C AA 43 Crystal Ball Tool 44 ls EE rss E ee rs ES E ES 44 Chapter 3 Crystal Ball Macro Calls Rie Aa da d e O Rd ld oda 47 De is S eee quar Cd qe wars A HPV e wdppe veces ony wa exa quede Sad bd as 50 CR AboglB x iueesueusoe esa rc TET 50 CB AboutBox Example seas wees Kae wees eae TEP T E Sesa 2 D0 e a A GR Bikes FRE ER we PRGA ES RSE EES ee CE AleitOnAmomentEnor Besmple sesos baad eee ewes E ACE AKA ikea Dl CB AlertOnArgumentError Related Calls oc occa needa cava cra 51 RIT a Poulet ridus PCT GB AlenOnMacroResultError Example as isa sese puote kray irarri NCA 52 Contents iii iv Contents CB AlertOnMacroResultError Related Calls RE yo ee TRE M CRANN ODETE E CBAlertOnO
17. 53 cbRunCapMetricsShort Boolean Value True or False Description Determines if the underlying forecast data should be considered short or long term True short term data and False long term data For Index 54 cbRunCapMetricsShift A numeric value indicating short term long term shift Sets the shift value used for calculating Zst and Zlt the default shift used in the Ul is 1 5 For Index 55 cbRunCapMetricsCalcType Integer Oor1 Determines if the capability metrics should be calculated from the fitted curve or the data O calculate from fitted curve and 1 calculate from data For Index 56 cbRunCapMetricsNormalityThresh Double Any positive value between O and 1 Specifies the p value threshold used for normality testing For Index 57 cbRunCapMetricsNormalCalcOptions Integer Oor1 Determines if the capability metrics should be calculated from the fitted curve or the data if the distribution is not normal O calculate from fitted curve and 1 calculate from data For Index 62 cbRunAlertLevel Integer cbRunAlertShowAIl 0 cbRunAlertShowImportant 1 cbRunAlertShowNone 2 Sets Crystal Ball to show alert messages according to the named constant or index value listed in the Value column For Index 65 cbRunAssumeZerosForUnspecifiedCorrs Boolean True or False Indicates whether to insert a zero into empty cells of a correlation matrix True
18. An error code that indicates what type of error the previous macro call encountered Variant For a list of the named constants and values that CB MacroResult returns see Table 160 In VBA subroutines and functions you can check the returned value against either the named constants or values All returned values are negative integers or 0 if no errors occur Note This function is for compatibility with the 2000 x 5 x versions of the Crystal Ball Developer Kit CB MacroResultDetail is recommended instead because it provides a wider range of errors CB MacroResult Example This example subroutine checkresult checks the last Crystal Ball macro call It uses the CB MacroResult return value to check the status of the last call and display the appropriate message Sub checkresult Select case CB MacroResult case cbErrNone MsgBox Completed OK case cbErrBadValue MsgBox Bad parameter value case cbErrNoForecastInCell MsgBox No forecast in active cell case cbErrNotReady MsgBox No simulation yet case cbErrNoAssumptionInCell MsgBox Missing assumptions in selected cell s case cbErrBadSelector MsgBox Bad value in parameter case cbErrBadCommand MsgBox Bad value in parameter parm number case cbErrNoCBSheets MsgBox No worksheets with CB information to save case cbErrTooManyAssumptions MsgBox Too many assumptions case cbErrTooManyForecasts MsgBox Too many forecasts case cbErrBadCorrelation MsgBox Invalid correlati
19. CB ChartPrefs re er er rr vee Beet eRe as ere ee d Ae o MMMM A 71 CRECIERON 71 CPAP NG arrancada da rra 72 Ra Eh MMM 74 CB ChartPrefsND Related Calls pede E RE ee Be ad AUS 74 INCURRA ar HEC OE OR ROREM A ECKE apo RR PEOR OE ECHO A N CB CheckData Example diaria DARA 74 CB CheckData Related Calls iia pr nn P 75 LRL DECRE NL deas a Red ER E ACE AAA AA e Raw EN ENS sx T9 DELIRDABNDEGSIBSE citas 75 CB CheckDataND Example 2 aa AA A A EORR A KR 76 CB CheckDataND Related Calls a Hs awed sa 76 o AAA 77 CB ClearData Example idque dese qi Quad qaad qd patada a 77 CB ClearData Related Calls redd us Se A PUR res java o CE barDatSND suits dew EQ SCC Ra FRU ER Rat Cr ER yo CH ERE LussxedotunbA RA eR E Rad ERA RR RC EX Rd kan 78 CB ClearDataND Related Call 12uusagusausp dA ER RAE tes RE ER RE OR RC 78 CIIU apra er e P 79 d Fe igo 3 AAA 79 CB CloseAllCharts Related Calle 22s4uecksahksuaecka dera PORE OR paa 79 CB CloseChart wees Rad eus ee ee Pus FTO TOU 79 CBC Du EMO A o e xA M GRAL DL Do Related Calli iria rra 80 CB CloseFore eee TN ee E Abd pies M ee T T 80 se IMA 80 GEA ite ee LAB lt lt rr pri ceva weed AA 81 e AAA eer ere ee re ee er eee ry 81 CB CloseSensitiv Example A beg EA sees TOTT 81 CD CloseSensiiy Related Calls AAA ta CATRAL AA Ad 82 CB CloseTrend Example ee ee
20. CB SelectDecVar Example This example activates the Model worksheet of the Futura with OptQuest xls workbook and selects all decision variables in the worksheet Workbooks Futura with OptQuest xls Worksheets Model Activate CB SelectDecVar 220 Crystal Ball Macro Calls CB SelectDecVar Related Calls Name Description CB SelectAssum Selects all assumptions in the current worksheet CB SelectFore Selects all forecasts in the current worksheet CB SelectFore This subroutine selects all forecasts in the current worksheet Before calling this subroutine activate the worksheet where you want to selectCrystal Ball data CB SelectFore Example This example activates the Model worksheet of the Futura with OptQuest xls workbook and selects all the forecasts on the worksheet Workbooks Futura with OptQuest xls Worksheets Model Activate CB SelectFore CB SelectFore Related Calls Name Description CB SelectAssum Selects all assumptions in the current worksheet CB SelectDecVar Selects all decision variables in the current worksheet CB SensPrefs Opens the Sensitivity Preferences dialog for the selected sensitivity chart either open or closed If more than one sensitivity chart is found opens a chooser dialog If no sensitivity chart has been defined this call creates a new chart with no associated forecast using the default preferences This chart then becomes the selected chart for
21. Clear CB MacroResultDetail Msg CB MacroResultDetail MsgDetails MsgBox CB MacroResultDetail MsgTitle CB MacroResultDetail NewValue CB MacroResultDetail OldValue CB MacroResultDetail Related Call Name Description CB MacroResult Indicates if a macro call worked correctly including limited error information CB OpenChart This call opens a chart of the specified type and chart ID The chart ID is optional If no charts of the specified type exist one is created and is selected If the chart ID is not specified the currently selected chart is opened If the specified chart is not found a chooser dialog appears No error is returned Currently this call only works on current and not restored results Table 161 CB OpenChart Parameters with Values VBA Data Parameter Type Value Description SimChartType Integer cbChtOverlay 1 cbChtScatter Specifies the type of chart you are opening overlay scatter 2 cbChtSensitiv 3 sensitivity or trend using the named constant and index cbChtTrend 4 values listed in the Value column ChartID Optional String Chart ID The chart ID returned by CB EnumChart Table 62 entered directly or using CB EnumChart CB OpenChart Example 1 This example opens the specified overlay chart trend chart and sensitivity chart CB OpenChart cbChtOverlay CB OpenChart cbChtTrend CB OpenChart cbChtSensitiv 196 Crystal Ball Macro Calls Over
22. Setting Up and Running Simulations The macro calls in this group can be used to e Identify errors CB MacroResult CB MacroResultDetail e Warn about errors e Handle Extreme Speed incompatibilities e Automate the definition of assumptions and forecasts e Select or copy paste or clear Crystal Ball data Opening and Closing Crystal Ball 39 Freeze data cells and run simulations The following sections describe macro calls that are used to set up and run simulations 40 CB AlertOnArgumentError on page 51 CB AlertOnMacroResultError on page 51 CB AlertOnObsolete on page 52 CB AutoDownshift on page 53 CB ClearData on page 77 CB ClearDataND on page 78 CB CopyData on page 82 CB CopyDataND on page 83 CB CorrelateND on page 86 CB CorrelateMatrixND on page 88 CB DefineAltParms on page 109 CB DefineAssum on page 112 CB DefineAssumND on page 113 CB DefineAssumFromForeND on page 117 CB DefineDecVar on page 119 CB DefineDecVarND on page 120 CB DefineFore on page 123 CB DefineForeND on page 123 CB Fit on page 139 CB Freeze on page 147 CB FreezeND on page 147 CB GetFitFilter on page 170 CB GetFitParm on page 171 CB GetLockFitParm on page 180 CB LockFitParm on page 191 CB MacroResult on page 192 CB MacroResultDetail on page 194 CB PasteData on page 199 CB Reset on
23. compatibility and is replaced by cbDfaMinExtreme and cbDfaMaxExtreme in later versions of Crystal Ball 1 A new distribution type betaPERT cbDfaBetaPert is added in Crystal Ball 7 3 CB GetFore To correct a documentation error the first parameter is now named ForeReference with a data type of Variant The Index parameter has these constant changes o cbForWindowSize 3 is obsolete and has been removed o cbPrecisionPerc 12 is renamed to cbForPrecisionPerc to correct a documentation error o cbPrecisionPercValue 13 is renamed to cbForPrecisionPercValue to correct a documentation error o cbForFilterGlobal 18 was obsolete in the Crystal Ball 7 1 version of the Developer Kit It is now valid and has been added back o cbForFrozen 19 cbForLSL 20 cbForUSL 21 and cbForTarget 22 are added CB GetForeStat New constants with index numbers 50 through 64 have been added to support Crystal Ball s process capability features 266 Changes from Previous Versions e Inversion 11 1 1 3 00 a new constant cbFstBaseCase 14 was added to return the base case initial value of a forecast cell CB GetRunPrefs e The additional parameters listed in the Developer Kit documentation for Crystal Ball 2000 5 5 5 cbRunStdError and cbRunBurstAmount are obsolete in this version of the Crystal Ball Developer Kit e Starting with Crystal Ball 11 1 2 1 000 cbRunAlertLevel 62 constants are added to specify the level of ale
24. 25 ile increments from O to 100 Integer inclusive For Index b cbBtsPercent cbBtsPercentQuintiles 4 Specifies quintiles 20 ile increments from O to 100 Integer inclusive For Index b cbBtsPercent cbBtsPercentDeciles 5 Specifies deciles 10 ile increments from O to 100 Integer inclusive For Index b cbBtsPercent cbBtsPercentlcosatiles 6 Specifies icosatiles 5 ile increments from 0 to 100 Integer inclusive For Index b cbBtsPercent cbBtsPercentCustom 7 Defines custom percentiles supplied by an optional Integer Value entry a one dimensional cell range containing percentiles If Value is omitted the default percentiles are 2 5 5 50 95 97 5 For Index 6 cbBtsSample cbBtsNumberSamples 1 Used with a Value entry to specify the number of Integer bootstrap samples to use For Index 6 cbBtsSample cbBtsTrialsPerSample 2 Used with a Value entry to specify the number of trials Integer to run for each bootstrap sample For Index 7 cbBtsForeOption cbBtsShowDefinedFore 1 Uses display settings for each forecast chart the Integer equivalent of the Show Forecasts As Defined dialog setting For Index 7 cbBtsForeOption cbBtsShowTargetFore 2 Shows only the target forecast the equivalent of the Integer Show Only Target Forecast dialog setting For Index 7 cbBtsForeOption cbBtsHideFore 3 Hides all forecasts the equivalent of the Hide All Integer Forecasts dialog setting Table 17 CB BootstrapND Value Parameter
25. 3 and cbDecVarTypeCustom 4 o cbDecCustomData 7 which supplies a data string for Value cbDecVarTypeCustom 4 CB SetFore e Data type returned changes from boolean to Variant e The first parameter name is changed from ForeRef to ForeReference to correct a documentation error e Index constant cbForWindowSize 3 is obsolete and is removed e Index constant cbForFilterGlobal 18 was obsolete in the Crystal Ball 7 1 version of the Developer Kit It is now valid and has been added back e Index constants cbForFrozen 19 cbForLSL 20 cbForUSL 21 and cbForTarget 22 are new e Value constants are removed or added accordingly CB SimResult e Was previously documented incorrectly in the Crystal Ball 2000 5 Developer Kit as CB SimResultND Changes to Existing Calls 269 CB Simulation Optional parameters HideForecasts MinimizeHost MinimizeAllSheets and StatusString have changed their data types to Variant ShowControlPanel is an optional boolean parameter added for Crystal Ball 7 0 Starting with Crystal Ball 11 1 1 0 00 the optional Asynchronous parameter is obsolete For placeholder purposes this parameter remains in the code and has been renamed to Obsolete_Asynchronous If any other optional parameters are used a double set of commas should appear between Iterations and the other optional parameters to show that there is another parameter with no value between them CB StartMultiSimul Has
26. CB BootstrapND CB CalculateSpearman CB CorrelateMatrixND Introduction 253 CB DataAnalysis CB DataAnalysisND CB DecisionTable CB DecisionTableND CB DefineAssumFromForeND CB GetAsmSensitivityChartGroup CB GetAssumStat CB GetBatchFitOption CB GetBootstrapOption CB GetCorrelationByRef CB GetDataAnalysisOption CB GetDecisionTableOption CB GetFitFilter CB GetLockFitParm CB GetScenarioAnalysisOption CB GetTwoDSimulationOption CB LockFitParm CB ScenarioAnalysis CB ScenarioAnalysisND CB SetAsmSensitivityChartGroup CB SetFitFilter CB TwoDSimulation CB TwoDSimulationND Added in Crystal Ball 7 1 7 3 x The following new calls have been added to previous versions of the Crystal Ball Developer Kit since Crystal Ball 2000 5 5 5 An asterisk indicates that the call has changed from the previous version in some way Check Changes to Existing Calls on page 257 for details CB AlertOnArgumentError CB AlertOnMacroResultError CB AlertOnObsolete CB AutoDownshift CB CBLoaded 254 Changes from Previous Versions CB CheckDataND CB CloseAllCharts CB CloseChart CB CloseSensitiv CB CloseTrend CB CopyScatter CB CopySensitiv CB CopyTrend CB CreateChart CB DefineAltParms CB DeleteChart CB EnumChart CB EnumCorrelation CB Fit CB Freeze CB FreezeND CB GetCBAutoLoad CB GetExcel2007ForegroundMode CB GetFitParm CB GetForeData CB GetVersion CB GetWorksheetVersion CB MacroResultDetai
27. Dist Integer See Table 79 Used to specify the distribution to use for fitting Values are listed in Table 79 Criterion Integer See Table 80 Used to specify which fitting statistics to return Values appear in Table 80 pValue Optional Boolean True or False If False returns the statistic if True returns the p value The default is False DistBestFit Integer See Table 79 If only one distribution is passed for Dist DistBestFit returns the index of that distribution Otherwise it returns the index of the best fitted distribution CriterionBestFit Integer See Table 80 If a specific ranking method is passed for Criterion CriterionBestFit returns the index of this ranking method Otherwise it returns the index of the selected ranking method The following table shows Dist parameter values used to select a distribution for fitting You can only fit to distributions listed in this table Table 79 CB Fit Dist Parameter Values Required Integer Named Constant Value Index Value Description cbDfaNormal 0 Fits to a normal distribution cbDfaTriangular 1 Fits to a triangular distribution cbDfaPoisson 2 Fits to a Poisson distribution cbDfaBinomial 3 Fits to a binomial distribution cbDfaLognormal 4 Fits to a lognormal distribution cbDfaUniform 5 Fits to a uniform distribution cbDfaExponential 6 Fits to an exponential distribution cbDfaGeometric T Fits to a geometric distribution cbDfaWeibul
28. Optional Integer Index Named Constant Value Value Description cbDecVarTypeContinuous O Sets the decision variable type to Continuous it can assume any value between the lower and upper bounds Continuous is the default type if decVarType is not used and StepSize is blank or 0 cbDecVarTypeDiscrete 1 Sets the decision variable type to Discrete it can assume values at specific intervals based on step size between the lower and upper bounds If decVarType is not used and StepSize is neither blank nor O the decision variable type is set to Discrete cbDecVarTypeBinary 2 Sets the decision variable type to Binary it can assume the value O represents No or 1 represents Yes Also known as the Yes No type cbDecVarTypeCategory 3 Sets the decision variable type to Category it can assume any integer between the upper and lower bounds inclusive without regard to order The bounds are also integers The decision variable values are nominal and represent choices or categories instead of arithmetic values For more information see CB DefineDecVarND Example 4 cbDecVarTypeCustom 4 Sets the decision variable type to Custom it can assume any value from a list of two or more specific values supplied with the customData parameter CB DefineDecVarND Example 1 This example defines a new decision variable in cell C9 with a lower bound of 400 an upper bound of 600 a step size of 10 also making the decision variable Dis
29. Optional Variant VBA Data Index Related Value Named Constant Value Type Value Description For Index2 A string containing a Microsoft Excel range String n a Specifies custom percentile cbBtsPercentCustom that holds desired percentile values The values to analyze values must be entered into Microsoft Excel as numbers not formatted as percentages can be decimals For Index2 A positive whole number Integer n a Number of bootstrap cbBtsNumberSamples samples to use For Index2 A positive whole number Long Integer n a Number of trials to run for cbBtsTrialsPerSample each bootstrap sample CB BootstrapND 65 CB BootstrapND Example 1 This example resets the Crystal Ball simulation selects a target forecast in cell A1 specifies the multisimulation method specifies analysis of custom percentiles included in the range F17 H17 specifies 100 bootstrap samples with 1000 trials per sample indicates that only the target forecast will display and then runs the Bootstrap tool CB ResetND Select target forecast A1 Select lt Al must contain a forecast CB BootstrapND cbBtsChooseTarget Select multisimulation method CB BootstrapND cbBtsMethod cbBtsMethodMultiSim Select what to analyze percentiles in this case CB BootstrapND cbBtsAnalyze cbBtsAnalyzePercent Select custom percentiles in the specified cell range CB BootstrapND cbBtsPercent cbBtsPercentCustom F17 H17 Set up samplin
30. ParmNumber Optional Variant 1 2 3 4 Specifies the target distribution parameter for Index equal to either coAsmParmName or coAsmParmValue Note For hypergeometric distributions whether the distribution was created in pre 7 0 releases with the Probability parameter or in later versions of Crystal Ball with the Success parameter index 17 for coDfaHypergeometricSuccess is always returned and the first parameter and value are Success not Probability Table 90 following shows named constant and index values for the Index parameter Note Index values cbAsmNumParms cbAsmParmName cbAsmParmValue cbAsmLowCutOff and cbAsmHighCutOff are not supported for custom distributions Table 90 CB GetAssum Index Parameter Values Required Integer Named Constant Value Index Value Description cbAsmName 1 Returns the assumption name cbAsmbDistType 2 Returns the index value of the distribution type See Table 55 cbAsmNumParms 3 Returns the number of distribution parameters cbAsmParmName 4 Returns the name of the distribution parameter indexed by ParmNumber cbAsmParmValue 5 Returns the value of the distribution parameter indexed by ParmNumber cbAsmLowCutOff 6 Returns the value of the lower truncation point cbAsmHighCutOff 7 Returns the value of the higher truncation point cbAsmDistFlag 8 Returns the extreme value distribution flag O cbFlgMinimum 1 cbFlgMaximum cbAsmFrozen 10 Returns True if t
31. Sets the lower specification limit LSL for the forecast 234 Crystal Ball Macro Calls Used With Specified Values of Index Value Description For Index 21 cbForUSL Variant A numeric value double a string Sets the upper specification limit USL for the representing a cell reference such as forecast B1 or coParmUndefined For Index 22 cbForTarget Variant A numeric value double a string Sets the target value for the forecast representing a cell reference such as B1 or coParmUndefined CB SetFore Example 1 This example changes the forecast in cell B7 to open the forecast window automatically during the simulation CB SetFore Range B7 4 True CB SetFore Range B7 5 O CB SetFore Example 2 This example turns on precision control for the forecast in cell B7 selects the absolute size of the confidence interval sets the size at 10 forecast units and selects the use of the mean in checking precision CB SetFore Range B7 6 True CB SetFore Range B7 7 True CB SetFore Range B7 8 10 CB SetFore Range B7 10 True CB SetFore Related Calls Name Description CB DefineForeND Defines forecasts in selected cells without a dialog CB GetFore Retrieves information for a specific forecast cell CB SetFore Changes the settings for a forecast CB SetRange This subroutine sets the certainty range for one or all forecasts Note Runa simul
32. True CB TwoDSimulationND cbTwoDOutputOption cbTwoDshowPercentiles True CB TwoDSimulationND cbTwoDPercent cbTwoDPercentCustom F17 H17 Set the max number of uncertainty simulations to display in output to 75 CB TwoDSimulationND cbTwoDMSDOption 75 Run the 2D Simulation tool CB Two2SimulationND cbTwoDRun CB TwoDSimulationND Example 2 This example runs the 2D Simulation tool using default preferences or settings from a previous run in the current Microsoft Excel session CB ResetND Run the 2D Simulation tool CB TwoDSimulationND cbTwoDRun CB TwoDSimulationND Related Calls Name Description CB TwoDSimulation Launches the 2D Simulation tool CB GetTwoDSimulationOption Returns current settings for the 2D Simulation tool CB WorksheetProtection Crystal Ball cannot run a simulation ifa cell with Crystal Ball data is located in a write protected worksheet This subroutine is used to supply Crystal Ball with a worksheet password After that Crystal Ball uses this password to unlock the worksheet while running and lock it again afterwards The following commands will work after CB WorksheetProtection is called e CB Simulation 250 Crystal Ball Macro Calls e CB SingleStep e CB Reset e CB ResetND e Microsoft Excel Save or SaveAs Note Other calls that define or modify Crystal Ball data such as CB DefineAssum and CB SetAssum also require unprotected worksheets before they will run However
33. a numeric value Long n a Specifies the number of trials to run for integer the scenario analysis For Index 7 True or False Boolean n a If set to True includes all forecasts in cbScelncludeNonTargetFore the output table if False includes only the target forecast Table 173 CB ScenarioAnalysisND Value2 Parameter Optional Variant VBA Data Index Related Value Named Constant Value Type Value Description For Index 3 PercentileMax a Double n a Specifies the maximum value of the cbSceSelectPercentiles numeric value percentile range to work on the minimum is specified as va1ue1 For Index 4 ForeValueMax a Double n a Specifies the maximum value of the forecast cbSceSelectForeValues numeric value value range to work on the minimum is specified as va1ue1 CB ScenarioAna This example resets the C lysisND Example rystal Ball simulation and then sets up and runs a scenario analysis as described by comments in the sample code CB ResetND Select target fore CB ScenarioAnalysisND cbSceChooseTarget Produce results ba CB ScenarioAnalysisND cbSceRangeForecastResults Use the range from CB ScenarioAnalysisND cbSceSelectPercentiles Show only the char CB ScenarioAnalysisN Run 500 trials CB ScenarioAnalysisND cbSceSimTrials the t Include only CB ScenarioAnalysisND cbSceIncludeNonTargetFore Run the tool CB ScenarioAnalysisN 218 Crystal Ball Macro Calls cast in cell B1
34. cbRptAssumCharts 11 Includes the distribution graph Boolean True includes the Integer 1 to 200 for each included assumption chart False does not defines the percent at the specified scale scale of the chart cbRptChooseAssum 12 Clears adds and sets the Integer See table Table 36 n a assumptions to include in the following report cbRptChartType 13 Selects the type of chart to Integer See Table 37 n a include in the report following cbRptOverlayChart 14 Includes all open overlay charts Boolean True includes the Integer 1 to 200 in the report at a specified chart False does not defines the percent scale scale of the chart cbRptExistingSheet 16 Creates the reportin an existing Boolean True creates the n a worksheet report in a new page of the existing workbook False creates the report in a new workbook cbRptSummary 17 Specifies which summary Boolean True includes the Integer See Table 38 information to include in the report parameter specified in Value2 False does not CB CreateRptND 93 Index Named Constant Value Value Description Value1 Optional Value2 Optional cbRptChooseDecVar 18 Clears adds and sets the list Integer See Table 39 n a of decision variables to include in the report cbRptDecVarBounds 19 Includes the bounds for each Boolean True includes the n a included decision variable bounds False does not cbRptDe
35. error CB CheckDataND on page 75 Checks Crystal Ball data cells for validity initializes variables without error prompting CB ClearData on page 77 Erases assumptions decision variables and forecasts from selected cells after prompting CB ClearDataND on page 78 Erases assumptions decision variables and forecasts from selected cells without prompting CB CloseAllCharts on page 79 Closes all open chart windows equivalent to Analyze then Close All CB CloseChart on page 79 Closes the selected chart of the given type CB CloseFore on page 80 Closes the forecast chart CB CloseSensitiv on page 81 Closes the selected sensitivity chart CB CloseTrend on page 82 Closes the selected trend chart CB CopyData on page 82 Copies Crystal Ball data in the specified range Alphabetic List of Crystal Ball Macro Calls 33 Name CB CopyDataND on page 83 Description Copies selected assumptions decision variables or forecasts CB CopyScatter on page 84 Copies the selected scatter chart to the clipboard CB CopySensitiv on page 85 Copies the selected sensitivity chart to the clipboard CB CopyTrend on page 86 Copies the selected trend chart to the clipboard CB CorrelateND on page 86 Defines a correlation coefficient between two selected assumptions CB CorrelateMatrixND
36. lt username gt Documents output txt Delivering Crystal Ball Runtime Applications 273 Startup Scripts Ideally users shouldn t need to manually start Crystal Ball You can use scripting to make sure that Crystal Ball automatically loads with Microsoft Excel or you can start the Crystal Ball launcher file CBLauncher exe installed with Crystal Ball to make sure Crystal Ball starts as follows e To ensure that Crystal Ball starts automatically when Microsoft Excel starts set the following registry key to a value of 3 HKEY CURRENT_USER Software Microsoft 0ffice Excel Addins SecureCBAddin Connect XLoadBehavior This is the same as checking the checkbox to automatically launch Crystal Ball when Microsoft Excel starts in the Crystal Ball Application Manager Note Be sure to set the registry key value back to 2 when the application closes OR e To confirm that Crystal Ball is running before you run any Crystal Ball Developer Kit code in the custom application call CBLauncher exe as follows C Program Files Oracle Crystal Ball Bin CBLauncher exe where the installation folder part of this call should be modified if CB is installed on a non English machine or to a non default installation folder OR e Youcan use new Crystal Ball Developer Kit calls to open and close Crystal Ball and determine load status CB CBLoaded CB GetCBAutoLoad CB SetCBAutoLoad CB Shutdown and CB Startup For more information about these calls s
37. managing charts 41 Microsoft NET Framework 278 295 Microsoft Excel add in creating 28 Microsoft Excel charts creating 98 multiple simulations starting 240 stopping 242 N namespace Predictor Developer Kit 295 namespace OptQuest Developer Kit 279 0 On Error GoTo 286 On Error Resume Next 286 opening CB forecast windows 197 charts 196 198 199 OptDFevKitRuntimeSample xls 284 optimization runtime classes 280 optimization setup classes 279 optimizations coding 285 OptQuest code development 282 OptQuest Developer Kit 277 278 installation 278 OptQuest Developer Kit classes important 279 OptQuest Developer Kit namespace 279 OptQuest Developer Kit sample 284 OptQuest development environment 282 OptQuest development resources 282 OptQuest wizard 287 OptQuest constraints and macros 291 OptRuntime class 281 OptRuntime OptCounters class 281 OptRuntime OptSolution class 281 OptRuntime OptVarSolutionFilter class 281 OptRuntime OptVarStatistics class 281 OptRuntime ResultsWindow class 281 OptRuntime RuntimeEfficientFrontier class 281 OptRuntime TestPointInfo class 281 Index 303 A B C D E F G H OptSetup class 280 OptSetup Constraint class 280 OptSetup Decision class 280 OptSetup Objective class 280 OptSetup OptEfficientFrontier class 280 OptSetup OptOptions class 280 OptSetup Requirement class 280 P parameters defining 109 pasting CB data 199 percentiles getting fro
38. the fit CB FormatPrefs on page 144 Opens the Chart Preferences dialog to set format preferences for the selected forecast CB FormatPrefsND on page 145 Sets format preferences for the selected forecast without a dialog CB Freeze on page 147 Defines which Crystal Ball data cells to hold to their spreadsheet values during a simulation using a dialog CB FreezeND on page 147 Defines which Crystal Ball data cells to hold to their spreadsheet values during a simulation without a dialog CB GetAsmSensitivityChartGroup on page 149 Returns the group name for an assumption in a sensitivity chart assumption group CB GetAssum on page 150 Retrieves information for a specific assumption cell CB GetAssumPercent on page 152 Calculates the value of the specified assumption that corresponds to the specified percentile CB GetAssumStat on page 154 Calculates the specified statistic for the assumption in the specified cell CB GetBatchFitOption on page 155 Returns current settings for the Batch Fit tool CB GetBootstrapOption on page 158 Returns current settings for the Bootstrap tool CB GetCBAutoLoad on page 160 Returns the current Crystal Ball autoload setting that indicates whether Crystal Ball is set to open whenever Microsoft Excel opens CB GetCertainty on page 161 Calculates the certainty level or probability of a
39. these calls are not affected by CB WorksheetProtection Worksheets must be manually unprotected before data modifying calls not listed previously will work Once the CB WorksheetProtection command has run on each protected worksheet and the workbook saved nothing else needs to be done for these commands to work Call CB WorksheetProtection with the sheet you want to protect active It only needs to be called through VBA for example from within the VBA Editor one time for each sheet Once the code has been run and the workbook saved the code can be deleted and Crystal Ball will remember the password for future simulations It does not matter if the sheet is already protected when CB WorksheetProtection is called as long as the password passed into the first parameter is consistent with the current worksheet password The password is encrypted so users cannot read it Table 214 CB WorksheetProtection Parameters Parameter VBA Data Type Value Description aPassword String Any alphanumeric string Specifies the user assigned password to register for that workbook aTurnon Boolean True or False Specifies whether or not workbook protection is active True activates protection and False removes it Use this option when you call this macro externally such as from Visual Basic CB WorksheetProtection Example 1 This example activates the target worksheet passes the password passwd runs a simulation and resets Crys
40. 188 Crystal Ball Macro Calls Table 152 CB GetWorksheetVersion Parameters Parameter VBA Data Type Value Description Worksheet Worksheet A Microsoft Excel object indicating the Indicates the target worksheet whose version to return Optional target workbook and worksheet If omitted returns the version of the currently active worksheet VersionType Variant Oor1 Returns the Crystal Ball version ID or build number as Optional a string For details see Table 150 Index Optional Integer An integer from 1 to the number of Returns the specified portion of the version ID or build sections in the string returned by number counting from left to right For details see VersionType Table 150 CB GetWorksheetVersion Example This example puts the third section of the build number of the version of Crystal Ball used to create the data on Sheet in cell A2 of the active worksheet and puts the version ID string of the version of Crystal Ball used to create Sheet 2 in cell B2 If the full build number is 11 1 159 0 and the version ID number is 11 1 1 1 00 159 is placed in cell A2 and 11 1 1 1 00 is placed in cell B2 Range A2 Value Range B2 Value CB GetWorksheetVersion Sheet1 cbFullBuildVersion 3 CB GetWorksheetVersion Sheet2 cbProductVersion CB GetWorksheetVersion Related Calls Name Description CB GetVersion Returns all or part of the current Crystal Ball version as a full build number or ve
41. CB Com Devkit chm in the Docs folder beneath the main Crystal Ball installation folder by default C Program Files Oracle Crystal Ball You can use this file as a reference at any time For more information on this help system and how to use it see CB Com Devkit chm on page 282 Developer Kit Use and Structure 295 If you select a class in the navigation pane its structure is outlined in the other pane with annotations Click any underlined link to learn more about that object Classes support functionality in the Predictor user interface UI To help you locate appropriate classes class names are designed to reflect the UI Predictor Setup Class Main classes for setting up validating and running Predictor e PredSetup main class interface for setting up and running Predictor e PredSetup PredInputData e PredSetup PredDataAttributes e PredSetup PredMethods e PredSetup PredOptions e PredSetup PredSeries PredSetup This is the top level interface class that provides access to objects to set and define all Predictor settings available through the Predictor wizard user interface The properties of this class enable access to classes that correspond to the wizard panels Input Data Data Attributes Methods and Options The methods of this class enable validation of input data and settings and also provide a method to run the time series forecast PredSetup PredInputData This class provides access to input data propert
42. CB SelectAssum Soe Raid nnn SWR PE TP bwi 219 E oi ohh he ERA PIE Re PASE thE EY dues sis 219 CR ode Rebasa 219 CE SERNA foci rose ae ear ORS EA Oe b pU A ERA Ae EN S ROCA ol EON back MIR A AM dec due ret a 4 ee e CB deett hart Related b ME os lead ech ri a iia 220 CBSelectDecVar aas quas ud texas calar 220 CB SelectDecVar Example wens bas TEP 220 CE Select ree vir R bhd Lala AA RE OR em a 3 27 00 D rrr TIPP mens CB SelectFore Example Ress pss 44 dd Pa Sees aoa Pad RS 221 GB eda Rd CUM cus dig deco RARA e eoe dee 221 A ath paar ison oe A Sud da qd RES 221 CE Sen Prek Exarupl s aae qaas aprilia 221 CB SensPrefs Related Call obey he wa AAA bes 222 CAOS ARA EIA KE OIA ERO AAA d x eda es re 2 CAS Pen Peale ccoo 223 CB SensPrefsND Related Call C ad ates 224 CRIAS GD c rr ee OEC RR He kae e end eee CE Setasmiensiivity hart stop Example 4 44 00s ee seer nh per kd a E any 224 CB SetAsmSensitivityChartGroup Related Call o ooooooooooooooo o 225 CU SECAS 2a ess xe ees ess bas M TE lt 225 CB SetAssum Example Q seu 226 LU Boet amp kssam Related Calls ocn ria a a taxa 226 CB SetCBAutoLoad pth tenon es 344 eee yi CB tCBAutoLoad FO ong pee eee dC Op ger Eo b e boe eee de CE ete BAutolsad AAA 227 CE SeCEWorkbookPriority A
43. CheckData Worksheets sheet3 Range F1 Offset 1 Value _ CB GetDecVar Worksheets Sheet1 Range B3 i Next i CB GetDecVar Related Calls Name Description CB DefineDecVar Defines or changes a decision variable in a selected cell using a dialog CB DefineDecVarND Defines or changes a decision variable in a selected cell without a dialog CB EnumDecVar Enumerates decision variable cells for all open workbooks CB SetDecVar Changes certain attributes for a decision variable CB GetExcel2007ForegroundMode This function is used in Microsoft Excel 2007 or later to retrieve the current setting for the Normal Speed preference Bring Microsoft Excel 2007 to the foreground while running Normal speed simulations faster When set to True that preference lets simulations run at optimal speed when using Normal speed in Microsoft Excel 2007 or later CB GetExcel2007ForegroundMode 169 Table 122 CB GetExcel2007ForegroundMode Returned Data Type Returned Value Returned Data Type The current foreground mode Run Preferences setting for Normal speed in Microsoft Excel 2007 orlater Boolean CB GetExcel2007ForegroundMode Example This example returns the current setting True or False for the preference Bring Microsoft Excel 2007 or later to the foreground while running Normal speed simulations faster in the Normal Speed options dialog accessed manually by choosing Normal Speed on the Speed tab
44. Crystal Ball Developer Kit subroutines and functions You can also use the Crystal Ball Developer Kit macros to create controls that extract data create charts and reports and more When you run simulations the Crystal Ball Control Panel is switched off by default However you can use Visual Basic or VBA to switch it on again using appropriate calls to CB Simulation or CB RunPrefsND Even if the Control Panel dialog is displayed though the Run Analyze and Help menus are hidden Your application can use any of the Crystal Ball features accessible through the Developer Kit If users have appropriate licenses you can also include Predictor time series analyses in your applications and users can run simulations in Extreme speed Unless otherwise specified defaults are pulled from the user s preference files These defaults can be set through Crystal Ball s preference dialogs or preferences macro calls such as CB RunPrefsND in the Crystal Ball Developer Kit For more information see Chapter 5 Crystal Ball Runtime CB RuntimeMode Example This example hides the Crystal Ball toolbar and menus resets the current simulation and runs a simulation of 5000 trials CB Runt imeMode CB ResetND CB Simulation 5000 CB RuntimeMode Related Call Name Description CB Simulation Runs a Crystal Ball simulation CB RuntimeMode 209 CB SaveResults This subroutine opens the Save Results dialog so you can save results da
45. DecisionTable Related Calls Name Description CB DecisionTableND Runs the Decision Table tool without displaying dialogs CB GetDecisionTableOption Returns current settings for the Decision Table tool CB DecisionTableND The Decision Table tool runs multiple simulations to test different values for one or two decision variables This call runs the Decision Table tool and displays results without using a dialog Note Before calling CB DecisionTableND reset the Crystal Ball simulation Table 47 CB DecisionTableND Parameters Parameter Required VBA Data Type Table Index Required Integer Table 48 106 Crystal Ball Macro Calls Parameter Required VBA Data Type Table Index2 Optional Integer Table 49 Value Optional Variant Table 50 Table 48 CB DecisionTableND Index Parameter Required Integer Named Constant Value Index Value Description cbDecChooseTarget 1 Sets the target forecast for the decision table operates on the forecast in the currently selected cell cbDecChooseDecVar 2 Used with rndex2 to select one or two decision variables for the decision table operates on the decision variable in the currently selected cell cbDecSimOption 3 Used with Index2 to set simulation options for the decision table cbDecForeOption 4 Used with rndex2 to set forecast display options cbDecRun 5 Runs the Decision Table tool when all settings have been specified Tabl
46. DefineAltParms in Crystal Ball 7 x and later versions including 11 x is different from Crystal Ball 2000 5 5 5 in that a different integer is returned for each call even if the parameters are the same This number is simply a pointer to the alternate parameter set Code written in Crystal Ball 2000 5 5 5 should run the same in Crystal Ball 7 2 or later including 11 x CB DefineAssum If a simulation was run earlier it must be reset before this call runs CB DefineAssumND If a simulation was run earlier it must be reset before this call runs The optional Dynamic parameter is deprecated in this release since all cell references are now dynamic It should not be used in new code An optional fourth parameter Parm4 is added to support the DistT ype constant cbDfaBeta which now has four parameters The following new constants are provided for DistType to support new distributions added in versions of Crystal Ball beginning with Crystal Ball 7 0 o cbDfaHypergeometricSuccess 17 o cbDfaMinExtreme 18 o cbDfaMaxExtreme 19 o cbDfaStudentsT 20 o cbDfaYesNo 21 o cbDfaDiscreteUniform 22 o cbDfaBetaPert 23 added in Crystal Ball 7 3 cbDfaHypergeometric 10 and cbDfaExtremeValue 15 are deprecated in this release Use cbDfaHypergeometricSuccess 17 instead of cbDFAHypergeometric 10 and use cbDfaMinExtreme 18 or cbDfaMaxExtreme 19 instead of cbDfaExtremeValue 15 Table 55 lists the values for Parm1 Par
47. Example This example runs 100 simulations with rescanning The array Median is filled with the values of the medians for each simulation in the multiple simulation Dim Median 50 As Double CB StartMultiSimul True For i 1 To 100 CB ResetND CB Simulation 1000 Median i CB GetForePercent Workbooks Futura with OptQuest xls _ Worksheets Model Range C7 50 Next i CB StopMultiSimul CB StartMultiSimul Related Calls Name Description CB Simulation Runs a simulation CB StopMultiSimul Marks the end of multiple simulations CB StartMultiSimul 241 CB Startup If Crystal Ball is not loaded into Microsoft Excel this function loads Crystal Ball It returns True when Crystal Ball is loaded Table 204 CB Startup Returned Data Type Returned Value Returned Data Type The current Crystal Ball load status Boolean CB Startup Example This example loads Crystal Ball and returns TRUE in cell B2 when loading is complete Range B2 Value CB Startup CB Startup Related Calls Name Description CB CBLoaded Indicates whether Crystal Ball is loaded in Microsoft Excel CB GetCBAutoLoad Returns the Crystal Ball autoload setting that indicates whether Crystal Ball is set to open whenever Microsoft Excel opens CB SetCBAutoLoad Sets or cancels autoloading with Microsoft Excel determines whether Crystal Ball is set to open whenever Microsoft Excel opens CB Shutdown Closes C
48. False True checks the precision of the mean False does not For Index 11 cbForPrecisionStdDev Boolean True or False True checks the precision of the standard deviation False does not For Index 12 cbForPrecisionPerc Boolean True or False True checks the precision of a percentile False does not For Index 13 cbForPrecisionPercValue Double 0 01 to 99 99 Sets the percentile value that Crystal Ball checks for precision For Index 14 cbForFilter Boolean True or False True turns on forecast filtering False turns it off For Index 15 cbForFilterlnside Boolean True or False True discards values inside the filtering range False discards values outside the range For Index 16 cbForFilterFrom Double Units Sets the lower bound of the filtering range For Index 17 cbForFilterTo Double Units Sets the upper bound of the filtering range For Index 18 cbForFilterGlobal Boolean True or False True applies the filtering settings to equivalent trials for all forecasts in a simulation False applies them only to the current forecast For Index 19 cbForFrozen Boolean True or False True freezes the forecast so it will not recalculate when a simulation runs False unfreezes the forecast For Index 20 cbForLSL Variant A numeric value double a string representing a cell reference such as B1 or coParmUndefined
49. False turns off the option Note Prefltem constant cbAssumShowCoordinates 2 is obsolete CB AssumPrefsND Example This example turns off the marker at the distribution mean for the assumption in cell A1 Range A1 Select CB ND cbAssumShowMean False CB AutoDownshift Subtopics e CB AutoDownshift Example 1 e CB AutoDownshift Example 2 This call specifies whether to automatically downshift to Normal speed when a simulation cannot run in Extreme speed and returns the current setting This setting is global It is in place for theentire Crystal Ball session The default setting is True which switches automatic downshift on If CB AutoDownshift is set to False and a simulation cannot run in Extreme speed the simulation fails and an error is returned CB MacroResultDetail CB MacroResultDetail on page 194 can return the reason for the failure CB AssumPrefsND 53 Note IfCB AutoDownshift is not called Crystal Ball acts as if it has been called with the default setting of True That is if a simulation cannot run in Extreme speed it is automatically downshifted to Normal speed and nothing is recorded in the error log because the simulation ran successfully You can test whether a simulation can run in Extreme speed by causing the simulation to fail when it cannot run in Extreme speed To perform the test explicitly call CB AutoDownshift and set it to False Table 7 CB AutoDownshift Returned Data Typ
50. FilterFrom Double Any valid double value Specifies the lower bound of the filtering range FilterTo Double Any valid double value Specifies the upper bound of the filtering range CB SetFitFilter Example See CB Fit Example 3 on page 142 CB SetFitFilter Related Calls Name CB Fit Description Fits a specific probability distribution to a range of data and returns information about the fit CB GetFitFilter Returns the current value of the specified distribution fitting filter setting CB SetFitRange Specifies the data range to use as input for CB Fit CB SetFitRange This function is used with CB Fit CB Fit on page 139 to specify a worksheet range that contains the set of data to fit to a distribution In a subroutine this call takes the form CB SetFitFilter 231 CB SetFitRange Range A1 A15 Table 194 CB SetFitRange Parameter Parameter VBA Data Type Value Description RangeRef Variant In a macro Range B3 Points to the cell range with the data to fit to a distribution CB SetFitRange Examples See the examples for CB Fit on page 139 CB SetFitRange Related Call Name Description CB Fit Fits a specific probability distribution to a range of data and returns information about the fit CB SetFore This function changes forecast attributes without redefining the forecast using CB DefineForeND Before you call this functi
51. GetScenarioAnalysisOption cbSceSelectPercentiles cbSceMaxValue Returns the Options setting cbSceShowTargetFore CB GetScenarioAnalysisOption cbSceForeOption Returns the number of trials to run 500 CB GetScenarioAnalysisOption cbSceSimTrials Returns whether to include only the target in the results False CB GetScenarioAnalysisOption cbSceIncludeNonTarget Fore CB GetScenarioAnalysisOption Related Calls Name Description CB ScenarioAnalysis Opens the Scenario Analysis tool wizard CB ScenarioAnalysisND Runs the Scenario Analysis tool without using dialogs CB GetTwoDSimulationOption This function returns specified settings made by CB TwoDSimulationND or the 2D Simulation tool Table 144 CB GetTwoDSimulationOption Returned Data Type Returned Value Returned Data Type The specified 2D Simulation settings Variant Table 145 CB GetTwoDSimulationOption Parameters Parameter Required VBA Data Type Table Index Required Integer Table 146 184 Crystal Ball Macro Calls Parameter Required VBA Data Type Table Valuel Optional Integer Table 147 Value2 Optional Variant Table 148 Table 146 CB GetTwoDSimulationOption Index Parameter Required Integer Value or Named Constant Index Description cbTwoDGetTarget 1 Returns the address of the selected target forecast for the 2D simulation operation operates on the forecast in the currently
52. However if you have used an All constant such as cbChfAll using cbChfClearList is overridden by the All constant and in this case information is still included for all forecasts For this reason it is good practice to use a Chosen constant after a ClearList constant CB Simulation 1000 CB CheckData CB CreateRptND cbRptSection True cbRptSectForecasts CB CreateRptND cbRptDefinedType cbRptCustom CB CreateRptND cbRptTrendCharts False CB CreateRptND cbRptSensitivityCharts True 150 100 Crystal Ball Macro Calls CB CreateRptND cbRp CB CreateRptND cbRp CB CreateRptND cbRp CB CreateRptND cbRp CB CreateRptND cbRp CB CreateRptND cbRp CB CreateRptND cbRp CB CreateRptND cbRp CB CreateRptND cbRp CB CreateRptND cbRp tOverlayCharts False tChooseFore cbChfAl1 tForeSummaries False tForeStatistics False tForeCharts True 50 tForePercentiles True cbPctDeciles tChooseAssum cbChaClearList tChooseAssum cbChaChosen tChartType cbChtExcel COK CB CreateRptND Example 2 This example resets any previously run simulation then clears the current assumption list adds B5 to the assumption list and turns on the assumption parameter option the second cbChaChosen use Other assumption preferences default to the current setting in the Create Report dialog Finally the example generates the report No forecast or simulation charts will appear since CB ResetND cleared all previous simulation information CB ResetND
53. Range B3 i Next i Notice that a message appears to indicate the third constant is obsolete and cell F3 is left blank 174 Crystal Ball Macro Calls CB GetFore Related Calls Name Description CB EnumFore Enumerates forecast cells for all open workbooks CB GetAssum Gets assumption cell information CB GetDecVar Retrieves information for a specific decision variable cell CB GetForePercent Gets a forecast cell percentile CB GetForeStat Gets a forecast cell statistic CB SetFore Changes forecast attributes without redefining the forecast CB GetForeData This function returns the value for the given trial for a specific forecast cell Note To call this function from a worksheet use the name CB GetForeDataFN Table 130 CB GetForeData Returned Data Type Returned Value Returned Data Type The value of the given trial for the specified forecast cell Variant Table 131 CB GetForeData Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 Points to the desired forecast cell In a worksheet B3 Index Long A whole number from 1 through the number of trials Number of the trial whose value you want in the simulation to return CB GetForeData Example 1 This example runs a simulation of 1000 trials and then pastes the value of the 100th trial of the forecast in B1 into cell A10 In a macro you can enter CB Simulatio
54. SaveResultsND This subroutine automatically saves results data and charts for the current simulation into the file specified by FileName Once you have saved a results file with cbr extension you can use CB RestoreResults or CB RestoreResultsND to open it and restore the results CB SaveResultsND is similar to CB SaveRunND available in Crystal Ball 2000 5 5 5 However CB SaveRunND stored an entire simulation not just the results CB RestoreRun and CB RestoreRunND were used to restore the saved simulation The existing simulation had to be reset before the saved simulation could be loaded and only one simulation could be restored at 210 Crystal Ball Macro Calls a time This differs from the current requirements for CB RestoreResults and CB RestoreResultsND discussed beginning in CB RestoreResults on page 202 Table 166 CB SaveResultsND Parameters Parameter VBA Data Type Value Description FileName String A path surrounded by quotes such as C temp Points to the results file where simulation results sheet2 cbr are saved Before running this subroutine run a simulation The simulation must be completed or stopped but not reset See the Oracle Crystal Ball User s Guide for more information on saving simulation results CB SaveResultsND Example This example runs a simulation of 1000 trials and then saves the simulation results to file Saveme cbr CB Simulation 1000 CB SaveResultsND C temp
55. Support Index Constant cbExtChooseDecVar Named Constant Value Index Value Description cbChooseDecVarAll 1 Includes all decision variables cbChooseDecVarChosen 2 Includes chosen forecasts Use after coChooseDecVarAdd cbChooseDecVarAdd 3 Adds the forecast in the selected cell to the list of chosen forecasts Use cbChooseDecVarChosen after this option cbChooseDecVarClearList 4 Clears the list of chosen forecasts 138 Crystal Ball Macro Calls Run a simulation before you call CB ExtractDataND Extraction of data from restored results is not supported See the Oracle Crystal Ball User s Guide for more information on extracting data CB ExtractDataND Example 1 This example runs a simulation and then sets preferences to extract the decile percentile data for all the forecasts It then extracts the data to a new worksheet in the active workbook CB Simulation 1000 CB CheckData CB ExtractDataND cbExtChooseFore cbChfAll CB ExtractDataND cbExtDataType cbDatPercentiles CB ExtractDataND cbExtPercentiles cbPctDeciles CB ExtractDataND cbExtExistingSheet True CB ExtractDataND cbExtOK CB ExtractDataND Example 2 You can now use CB ExtractDataND to extract more than one type of data To do this use cbExtDataType followed by the type of data and then follow that by a boolean Value2 parameter For example the following lines of code extract both statistics and values CB CheckData CB ExtractDataND cbExtDat
56. T mobs awa E Poes oe Sib 2a DE CECI ee Rekted CO cia as eee oe nos 82 FA po e P 82 CB CopyData Example girar 83 CB CopyData Related Calls bas ees seus B3 CB CopyDataND sonas ARES EA A AA AA sas UA LBLopyDalaD EPE nens ardid AA sd 84 CB CopyDataND Related Calls pierdo ied 84 deli oul 0 q MM D ucro 84 CRC ESE vaa d vade ed es A A AA sese us 84 LB Lopy5odtter Related Calls conca arrancada 85 Ae Lace dead roodo pror aoa Dre dw eodd c ar dr ed d fe dora 85 Contents v vi Contents CB CopySensitiv Example yas Eins ans eee a a oe Oe CB CopySensihy Related Calle cepto ADAN RRA 85 CBCopylrend sacara r M or rc ee ee eee POP 86 CB CopyTrend Example T paws ku eee da aes er 86 Gam rend Related Calls da AA AA EIA 86 CB CorrelateND aiii eT A eT eee ee eee oe kb des 86 CB CorrelateND Examplel CP n 87 CB CorrelateND Example2 abs ass 87 CLIO DRUSI Dir A a RA a A 87 CluConduexD Rebied Calls rara a ata 88 CB CorrelateMatrixND Pays seus Kus 334 odei TTEN 88 CB CorrelateMatrixND Example 1 ceed accent Re ry ER da RR X FXAu RES 89 CB Cad Aaa ND eee cd ARA OC IG d RARA 90 CH ComclateMatrixND Example 3 orina corner 90 CB Cortese Matin Exauupled iuadqeasaaborg kuopem guas ea BY CE CorrelateMatrie ND RA A RYE 90 C
57. The following Index constants are added cbExtDataOptimizerType 14 cbExtChooseDecVar 15 o The following Value constants are added for cbExtDataOptimizerType cbDatOptimizerSolutions 1 cbDatOptimizerStatistics 2 o The following Value constants are added for cbExtChooseDecVar cbChooseDecVarAll 1 cbChooseDecVarChosen 2 coChooseDecVarAdd 3 cbChooseDecVarClearList 4 To support the rewritten version of Predictor added in version 11 1 1 3 00 the following Index constants are added cbExtPredictorResultsSheetName 17 cbExtPredictorMethodsSheetName 18 cbExtPredictorResultsHistorical 19 cbExtPredictorResultsFitted 20 cbExtPredictorResultsForecast 21 cbExtPredictorResultsConfidence 22 cbExtPredictorResultsResiduals 23 cbExtPredictorMethodsErrors 24 cbExtPredictorMethodsStatistics 25 cbExtPredictorMethodsParameters 26 and cbExtPredictorMethodsRanking 27 CB Fit CB Fit must now be used with CB SetFitRange to select the range of data to fit to a distribution Constants have been added to support distributions added in Crystal Ball 7 cbDfaMinExtreme 18 cbDfaMaxExtreme 19 cbDfaStudentsT 20 and cbDfaBetaPert 23 added in Crystal Ball 7 3 Constant cbDfaExtremeValue 15 is deprecated It is included for Crystal Ball 2000 5 5 5 compatibility and is replaced by cbDfaMinExtreme and cbDfaMaxExtreme in later versions of Crystal Ball Criterion constant cbFitChiSquareP 2 has been added
58. Values Required Integer Named Constant Index Description cbChtOverlay 1 Enumerates overlay charts cbChtScatter 2 Enumerates scatter charts cbChtSensitiv 3 Enumerates sensitivity charts cbChtTrend 4 Enumerates trend charts CB EnumChart 127 CB EnumChart Example This example initializes all internal variables then steps through all the overlay charts returns their paths and names and puts this information in column C of a worksheet CB Simulation 1000 CB CheckData Dim ChartID As String Dim t As Integer ChartID CB EnumChart cbChtOverlay t 0 While ChartID lt gt Range C2 Offset t Value ChartID t t 2 ChartID CB EnumChart cbChtOverlay Wend CB EnumChart Related Calls Name Description CB CheckData Checks decision variables for validity initializes variables CB CreateChart Creates a new chart of the specified type with the optional name if specified CB SelectChart Selects the chart with the specified chart ID CB EnumCorrelation This function lists correlated assumption cells and their correlation values for all open workbooks This command is useful for determining what correlated assumptions have been defined for the open workbooks You can then call CB GetAssum for each assumption to retrieve specific information for example distribution type and parameters Linked correlations are displayed at the end of the enumeration order for each worksheet
59. a message when an execution error occurs CB AlertOnObsolete on page 52 Displays a message when an obsolete call or constant is used CB AssumPrefsND on page 53 Sets attributes of Crystal Ball assumptions CB AutoDownshift on page 53 In Crystal Ball Decision Optimizer determines whether to automatically downshift to Normal speed or fail when a model is incompatible with Extreme speed CB BatchFit on page 54 Launches the Batch Fit tool CB BatchFitND on page 55 Runs the Batch Fit tool without displaying dialogs CB Bootstrap on page 63 Launches the Bootstrap tool CB BootstrapND on page 63 Runs the Bootstrap tool without displaying dialogs CB CalculateSpearman on page 67 Calculates Spearman rank correlations between pairs of values CB CBLoaded on page 67 Indicates whether Crystal Ball is currently loaded within Microsoft Excel CB CellPrefs on page 68 Sets attributes of Crystal Ball cells using a dialog CB CellPrefsND on page 69 Sets attributes of Crystal Ball cells without using a dialog CB ChartPrefs on page 71 Sets chart preferences for the selected forecast using a dialog CB ChartPrefsND on page 72 Sets chart preferences for selected forecast without a dialog CB CheckData on page 74 Checks Crystal Ball data cells for validity initializes variables with dialogs in case of
60. aWasStoppedOnPrecision True if stopped on precision control e aHasNewBestSolution New value of objective 30 Crystal Ball Developer Kit Overview CBBeforeTrial Public Function CBBeforeTrial aTrial As Long As Integer the code is here End Function CBAfterTrial Public Function CBAfterTrial aTrial As Long As Integer the code is here End Function CBAfterRecalc Public Function CBAfterRecalc aTrial As Long As Integer the code is here End Function Priority Rules The following rules govern the running order of macros e If multiple workbooks are open Crystal Ball searches the workbooks in the order of their priority The priority number is set by the CB SetCBWorkbookPriority macro If this macro has not been called on the workbook no workbook order is guaranteed CB SetCBWorkbookPriority sets the running order for macros when multiple workbooks are open For example a workbook with order 10 will run before a workbook with order 20 CB SetCBWorkbookPriority runs only at the workbook level and not at the worksheet level The definition of this macro is Public Function CB SetCBWorkbookPriority aPriority As Long A syntax example used in a subroutine at the module level is Application Workbooks Bookl xls Activate CB SetCBWorkbookPriority 10 This example assigns a priority of 10 to the workbook Book1 xls e Within each workbook macros on worksheets run in left to right sheet order in the workbook prov
61. and Custom StepSize Variant Number less than Max Min Specifies a positive step size for discrete decision variables If Optional decVarType is not used indicates whether the decision variable type is Continuous StepSize is O or blank or Discrete StepsSi ze is greater than 0 ignored for decision variable types Binary Category and Custom NameOf Variant Title surrounded by quotes Specifies how Crystal Ball identifies the decision variable Names the Optional decision variable If you do not specify a name Crystal Ball uses the first of either the cell s range name text from the cell in the column immediately preceding it to the left text from the cell in the row immediately preceding it above or the cell s coordinates decVarType Integer See Table 58 Sets the decision variable type to Continuous Discrete Binary Optional Category or Custom described in Table 58 customData String A list of at least two values Supplies a list of values for use with the Custom decision variable type Optional separated by commas ora cbDecVarlypeCustom reference to a range of cells containing these values decimal values can be used The range must be one dimensional adjoining cells in one row or one column 120 Crystal Ball Macro Calls Note The decVarType and customData parameters are added for Crystal Ball 11 x Table 58 Named Constant and Index Values for the decVarType Parameter
62. as listed in Table 55 cbBftRankMethod 11 Returns the constant of the selected fit ranking method as listed in Table 80 cbBftOutputLocation 12 Returns the constant of the selected output location setting a new workbook the current workbook a new worksheet or the current worksheet cbBftNewWorkbook 1 cbBftCurrentWorkbook 2 coBftNewWorksheet 3 or cbBftCurrentWorksheet 4 If coBftCurrentWorksheet is returned you can use cbBftOutputLocationCell 25 to return the starting cell cbBftOutputFormat 13 Returns a boolean to indicate whether the output is formatted True cbBftOutputCorrelationMatrix 14 Returns a boolean to indicate whether a correlation matrix is produced True cbBftLinkToCorrelationMatrix 16 Returns a boolean to indicate whether there is a link to the matrix of correlations between the data series True assuming cbBftOutputCorrelationMatrix 14 is set to True cbBftOutputGoodnessOfFitReport 17 Returns a boolean to indicate whether a goodness of fit report is produced True if True use cbBftOutputGoodnessOfFitSheet 27 to return the sheet name of the report cbBftOutputAssumReport 18 Returns a boolean to indicate whether an assumption report is produced True if True use cbBftOutputAssumSheet 28 to return the sheet name of the report 156 Crystal Ball Macro Calls Named Constant Value cbBftOutputAssumFullStatistics Index Value 19 Description If cbBftOutputAssumReport 18 is True can be used t
63. assumptions in cells B6 C7 and D8 created in CB CorrelateND Example 3 on page 87 CB CorrelateMatrixND Range B2 D4 False cbCorrMatrixDelete Range B6 C7 D8 CB CorrelateMatrixND Related Calls Name Description CB CorrelateND Defines a correlation coefficient between two selected assumptions CB DefineAssum Defines or changes assumptions in selected cells using a dialog CB DefineAssumND Defines or changes assumptions in selected cells without using a dialog CB CreateChart This function creates a new chart of the specified type and returns the chart ID of the new chart Optionally you can specify the name If successful the new chart becomes the selected chart for subsequent chart calls If the chart is not created successfully an empty string is returned 90 Crystal Ball Macro Calls Table 30 CB CreateChart Returned Data Type Returned Value Returned Data Type The path and name of the new chart of the specified type ChartlD in the format String Current Results Sensitivity Charts Charts xls Sensitivity Chart 1 Table 31 CB CreateChart Parameters and Constants VBA Data Parameter Type Value Description SimChart Type Integer cbChtOverlay 1 cbChtScatter Specifies the type of chart you are creating overlay 2 cbChtSensitiv 3 cbChtTrend scatter sensitivity or trend chart For named constant and 4 index values see the Value column DisplayName Strin
64. back in Crystal Ball 11 1 1 0 00 to show the Chi square p value A new optional boolean parameter pValue is added to display p values instead of statistics when set to True 264 Changes from Previous Versions e Starting with Crystal Ball 11 1 1 0 00 discrete distributions can be used for fitting and Crystal Ball will also select distributions and a ranking method automatically when requested The following new Dist parameter constants support new distribution fitting options cbDfaAutoSelectDist 50 coDfaAllContinuous 51 cbDfaAllDiscrete 52 and cbDfaAllDistributions 53 A new Criterion parameter constant cbDfaAutoSelectRanking Method 5 has been added to support automatic selection of the ranking method CB Freeze and CB FreezeND e These calls replace CB FreezeAssum and CB FreezeAssumND This change reflects the new functionality in Crystal Ball versions later than 2000 5 5 5 that can freeze decision variable and forecast cells as well as assumptions CB GetAssum e To correct a documentation error the parameter name AssumRef is changed to AssumReference to match the code The data type is now Variant CB GetAssumPercent e The data type of the Percent parameter is now Double CB GetBatchFitOption e Starting with Crystal Ball version 11 1 2 1 000 two new constants are added to Index o cbBftOutputOrientation 30 which returns cbBftOutputRows 1 or cbBftOutputColumns 2 o cbBftOutputSheetName 31 which r
65. base case initial value of the forecast cell cbFstCp 50 Returns the Cp for short term data or Pp for long term data cbFstCpklower 51 Returns the Cpk lower for short term data or Ppk lower for long term data cbFstCpkupper 52 Returns the Cpk upper for short term data or Ppk upper for long term data cbFstCpk 53 Returns the Cpk for short term data or Ppk for long term data cbFstCpm 54 Returns the Cpm for short term data or Ppm for long term data cbFstZLSL 55 Returns the Z LSL cbFstZUSL 56 Returns the Z USL cbFstZst 57 Returns the Z st cbFstZlt 58 Returns the Z It 178 Crystal Ball Macro Calls Named Constant Value Index Value Description cbFstpNCbelow 59 Returns the p N C below LSL cbFstpNCabove 60 Returns the p N C above USL cbFstpNCtotal 61 Returns the p N C total cbFstPPMbelow 62 Returns the PPM below LSL cbFstPPMabove 63 Returns the PPM above USL cbFstPPMtotal 64 Returns the PPM total Note To use CB GetForeStat in a worksheet use the integer value of the Index parameter The named constant will not work If no mode is calculated Index cbFstMode returns VALUE CB GetForeStat Example 1 This example runs a simulation of 1000 trials and then pastes the standard deviation of the forecast in B7 into cell M6 In a macro you can enter CB Simulation 1000 Range M6 Value CB GetForeStat Range B7 cbFstStdDev CB GetForeStat Example 2 This example before a simulation d
66. calls have equivalents with names ending in FN that can be used directly in models For a list of these see Spreadsheet Functions For Use in Microsoft Excel Models on page 38 Calling Crystal Ball From Visual Basic For Applications VBA Programs To call Crystal Ball subroutines and functions from VBA programs ensure that the following conditions are true e Crystal Ball must be running e The VBA program must have a reference to Crystal Ball To create a reference to Crystal Ball from your programs 1 Open your VBA program In Microsoft Excel for example select Tools then Macro and then Visual Basic Editor 2 Inthe menu select Tools then References 3 Look in the Available References list for CBDevKit e Ifthe reference appears in the list check it and click OK e Ifthe reference does not appear in the list continue with step 4 4 To locate and load the code module click Browse Browse to the main Crystal Ball installation folder by default C Program Files Oracle Crystal Ball 6 Change Files Of Type to Excel Files xls xla 1 Double click CBDevKit xla CBDevkKit appears in the Available References list with a check in front of it 26 Crystal Ball Developer Kit Overview Note Ifyou upgraded from 2000 x 5 x versions of the Crystal Ball Developer Kit locate cb xla in the Available References list and uncheck it 8 Click OK CBDevKit appears as a project where you can access the CB module Note Ifyou
67. cbCelRangeMax True or False n a For decision variable cells True changes the cell value to Boolean the range maximum False leaves the existing values in the cells CB CellPrefsND Example This example changes cell preferences for assumption cells including both existing and future assumptions It turns off any pattern changes the color to cyan and displays assumption cell notes CB CellPrefsND cbCelAssum CB CellPrefsND cbCelAssum CB CellPrefsND cbCelAssum 70 Crystal Ball Macro Calls cbCelPattern cbCelColor 8 0 False False cbCelNote True False CB CellPrefsND Related Calls Name Description CB CellPrefs Displays the Cell Preferences dialog CB ChartPrefs Subtopics e CB ChartPrefs Example e CB ChartPrefs Related Calls This subroutine opens the Chart Preferences dialog for the selected assumption or forecast cell so you can change the chart preferences If an assumption or forecast cell is not selected error code 5102 appears from CB MacroResultDetail NewValue Before calling this subroutine to change the chart preferences for a particular assumption or forecast chart select the corresponding cell Note Requirements for this subroutine are slightly different than for Crystal Ball 2000 5 5 5 For 2000 x 5 x versions you could use this subroutine without selecting a cell to set default forecast chart settings CB ChartPrefs Example This example runs a simulatio
68. cbDecSimOption cbDecNumValuesVar2 10 Set maximum number of trials per simulation CB DecisionTableND cbDecSimOption cbDecSimTrials 500 Hide forecast chart windows during simulation CB DecisionTableND cbDecForeOption cbDecHideFore Run the Decision Table tool CB DecisionTableND cbDecRun CB DecisionTableND Related Calls Name Description CB DecisionTable Launches the Decision Table tool 108 Crystal Ball Macro Calls Name CB GetDecisionTableOption Description Returns current settings for the Decision Table tool CB DefineAltParms This function creates or changes an alternate parameter set for continuous distributions listed in Table 55 The function returns a value used by CB DefineAssumND Note Ifyou use CB DefineAltParms to define an alternate parameter set using only percentiles you will not be able to retrieve parameter values with CB GetAssum Table 51 CB DefineAltParms Returned Data Type Returned Value Returned Data Type An encoded integer that indicates the distribution and parameter set that CB DefineAssumND should use Integer Note A return value of 1 indicates an improperly defined alternate parameter set Table 52 CB DefineAltParms Parameters VBA Data Parameter Type Value Description DistType Integer Integer value or named Specifies a distribution type for the assumption The number of parameters constant See Table 55 varies with th
69. contain values and not formulas In the following command B5 B6 and B7 are all assumptions Range B5 B7 Select CB CopyData Range D1 D3 Select CB PasteData CB PasteData Example 3 This example copies the Crystal Ball data from cell B5 and pastes it three times into cells D1 D2 and D3 Range B5 Select CB CopyData Range D1 D3 Select CB PasteData 200 Crystal Ball Macro Calls CB PasteData Related Calls Name Description CB CopyData Copies Crystal Ball data in specified range CB Reset This subroutine resets the current simulation prompting you to confirm the reset When you confirm it closes all forecast windows the trend chart the overlay chart and the sensitivity chart then it clears results from the previous simulation This is very useful to use before calls to subroutines and functions that require that a simulation be reset such as CB Freeze although you might prefer CB ResetND because it resets automatically without user response You can also call this subroutine to make sure that simulations start at Trial 1 You do not have to run a simulation before you call this subroutine However it is convenient to run to ensure that no prior simulation results are around Note Ifyou run a simulation using the CB Simulation subroutine without resetting Crystal Ball runs additional trials and adds the results to the existing results This is different from the user interface comma
70. data values are used Table 91 CB GetAssumPercent Returned Data Type Returned Value Returned Data Type Assumption value that corresponds to the specified percentile Variant 152 Crystal Ball Macro Calls The percentile is calculated based on the assumption s distribution Any truncation points are factored into the percentile calculation Note Reversing the percentiles using the cbRunReversePercentile option does not affect the output of this function For more information see CB RunPrefsND on page 204 Table 92 CB GetAssumPercent Parameters Parameter VBA Data Type Value Description AssumReference Variant In a macro Range B3 Points to the desired assumption cell In a worksheet B3 Percent Double A number between O and 100 Specifies the percentile for which you want the assumption value CB GetAssumPercent Example 1 This example runs a simulation of 1000 trials and then puts the values for every fifth percentile into an array called Percents In a macro you can enter CB Simulation 1000 Dim Percents 19 As Double For i 1 To 19 CB CheckData Percents i CB GetAssumPercent Range C9 i 5 Next i CB GetAssumPercent Example 2 This example enters the value at the 50th percentile of the assumption distribution in cell B3 In a worksheet cell you can enter CB GetAssumPercentFEN B3 50 CB GetAssumPercent Related Calls Name Description CB EnumAssum Enume
71. desaxeo dE ra REARRRXKRE AE AREA RECHTE 238 CB Simulation toed d dd add o 238 CE Smula EI prosa es rd ps a EN AMAN EZ cr AA AA A 239 CB Simulation Related Calls A EIEE iss 240 CB SingleStep 4 es 24 er irnos 240 CB SingleStep Example iade E QE at E CL E 240 ei a IA 240 CB StartMultiSimul ades 44 ped dede ads ade 240 CD Stalb Pestle iia aem pk rs ROO e Corea BA CE Sia Malt Related Calls ccucccusscequcues criador e 241 e 2ad uas oqueadqaseqiqaxecied saeeepq emesxenqhqadecu aqKqaas es 242 peal ull Ana 242 CB Startup Related Calls Yes ads 242 MAA 242 CB StopMultiSimul Related Calls rra Ad 242 CBTrendPrefs ous Kees EA EII A Kees ee 243 CB TrendPrefs pia mc ou 243 LB Tara DO LM a ee Dk Kato bic scit capa d dates iea 243 CB IrendPreND 22x n inicia 243 CB TrendPrefsND Example kan dabas 246 CB TrendPrefsND Related Call ca cigar ceded eee AA 246 CT rh Cases aeecerausessuepasekr preseqepPadorbee rdibequees 246 CB TwoDSimulation Example Se A TP bwi 246 CE TwoDSimulation Rdated Calls rra das s3 287 Cb DeoDSuimilati nND lecitina a 247 CE TwoDSimulationND Example 1225 22 22 za AAA 249 GB TwoDSumolsdon D Example 2 un ausa qa yop eb orae goes dee 250 CB TwoDSimulationND Related Calls 151 2244 uaa RR EA ERE 250 CB WorksheetProtecton 5222
72. e ObjReqBase Class iB OptCondition Type Enumeration B OptConstraint Type Enumeration E e OptCounters Class El OptDecision Type Enumeration E OptEFFBoundType Enumeration e OptEfficientFrontier Class E OptEFFSelection Type Enumeration E OptEFFTest Type Enumeration E e OptimizationEvents Interface E OptimizationState Enumeration E OptMoreLessCondition Enumeration a OptObjective Type Enumeration E OptOptimization Type Enumeration E OptOptions Class E OptRunForType Enumeration E Q amp OptRuntime Class E OptRuntime AfterSimulationEvent Handler Delegate E OptRuntime Efficient FrontierEventHandler Delegate E OptRuntime OptEventHandler Delegate amp em Print Options CB Com Dev Hp pH y y Hg Constrain Decisioneering CB CBCOMDevKit Optimization Namespace ElCollapse All gt Language Filter kit Constraint Properties Properties 4 Public J Instance Protected 2 Static Member Comment ConstraintType EFDisplayName Equation Exclude OptimizationStatistics See Also t See Also The Constraint type exposes the following properties J XNA Framework 4 Declared Only A Inherited J NET Compact Framework Only Description Var comment Inherited from OotVar Is constraint linear Var display name Inherited from OotVar Var Efficient Frontier display name empty string if var is not defined as Efficient Frontier Inherited from OptVar Constr
73. extracted data values will have been written to the workbook as part of the simulation processing Forecast objective and requirement values have not yet been updated to OptQuest Note at this point any solution values for this iteration are not yet valid User defined Event Macros for Optimizations 287 Event Type Runs AfterlterationEvent Optimization After each iteration of an optimization The simulation is complete any extract data has been written to the workbook and objective and any requirement values have been updated to OptQuest Note at this point all solution values for this iteration are valid AfterOptimizationEvent Optimization After an optimization is complete EfficientFrontierEvent Optimization After each test point in an Efficient Frontier optimization is complete The BeforeOptimizationEvent macro runs at the beginning of the optimization when the Run button is first clicked or the Run command is given After that the Simulation and Iteration event macros take over and run as described until all requested trials and simulations have been run or a stopping point set in the Advanced Options dialog has been reached At that point the optimization is complete and the AfterOptimizationEvent macro runs Using Events in VBA To use these events in Microsoft Excel VBA open the Microsoft Excel Visual Basic Editor and open a code window for a workbook Begin by explicitly declaring the C
74. for Optimizations 289 MaxTrials As Long _ Progress As Double _ WasAborted As Boolean _ WasStoppedOnError As Boolean _ WasStoppedOnPrecision As Boolean _ HasNewBestSolution As Boolean Your code is here End Sub In this signature parameters or arguments are defined as follows e IterationsCompleted Number of iterations completed e Trials Number of trials completed for this simulation e MaxTrials Number of trials scheduled to run total trials per simulation e Progress Percent of trials completed expressed as a decimal 0 to 1 0 e WasAborted True if manually stopped e WasStoppedOnError True if stopped on error e WasStoppedOnPrecision True if stopped on precision control e HasNewBestSolution New value of objective for optimizations was this a new best solution AfterlterationEvent Private Sub PortfolioOptRuntime AfterlterationEvent IterationsCompleted As Long Your code is here End Sub In this signature parameters or arguments are defined as follows e IterationsCompleted Number of iterations completed AfterOptimizationEvent Private Sub PortfolioOptRuntime AfterOptimizationEvent IterationsCompleted As Long Your code is here End Sub In this signature parameters or arguments are defined as follows e IterationsCompleted Number of iterations completed EfficientFrontierEvent Private Sub PortfolioOptRuntime EfficientFrontierEvent TestValue As Double Your code is here End Sub In thi
75. in the Examples folder a sample spreadsheet with commented code so you can follow how the OptQuest Developer Kit was used to create several sample optimizations see OptDevKitRuntimeSample xls on page 284 for details e CB Com Devkit chm in the Docs folder an online help file that describes the methods and properties within each class of the OptQuest Developer Kit see CB Com Devkit chm on page 282 for more information What You Will Need Crystal Ball Decision Optimizer runs on several versions of Microsoft Windows and Microsoft Excel For a complete list of required hardware and software see the current Crystal Ball Installation Guide OptQuest Developer Kit Use and Structure This section gives specific requirements for installing and using the OptQuest Developer Kit It also summarizes the structure of the Developer Kit and introduces CB Com Devkit chm a help file that serves as an online reference to the classes methods properties and other elements of the OptQuest Developer Kit Specific Requirements for Use If you have a license to run OptQuest you can use the OptQuest Developer Kit and run applications built with it The following sections outline specific requirements for its installation and use Installing the OptQuest Developer Kit If you are licensed to use OptQuest as part of Crystal Ball the OptQuest Developer Kit is automatically available when you install Crystal Ball and is immediately available for
76. maximum number of trials For Index 46 cbRunPrecision Confidence Double Any value between 0 01 and 99 99 Setting for coRunPrecisionConfidence sets the confidence level as a percentage for precision control For Index 47 cbRunReversePercentiles Boolean True or False True makes percentiles represent the percentage of the distribution greater than the percentile value False makes percentiles represent the percentage less than the value For Index 48 cbRunFormatPercentiles Boolean True or False Determines whether percentiles are indicated by a percent sign 10 or by a P before the value P10 True uses the P and False uses the sign For Index 49 cbRunSaveAssumptionValues Boolean True or False True saves assumption values for later analysis such as sensitivity analysis False discards them For Index 50 cbRunLeaveOpenOnReset Boolean True or False True leaves the CB Control Panel open when a simulation is reset False closes it For Index 51 cbRunUserMacros Boolean True or False Indicates whether or not to run user defined macros True runs them and False does not run them For Index 52 cbRunCapMetrics Boolean True or False Sets whether the Ul should display capability metric related information True shows metrics and False does not show capability metrics CB RunPrefsND 207 Used With Specified Values of Index For Index
77. nia dei O NER Ru RUE 247 CB Workelee PIOTBEDUIL aria AAA A 250 Introduction This chapter defines all currently available Crystal Ball Developer Kit macro calls subroutines and functions When calls are compared with those in Crystal Ball 2000 5 5 5 the comparisons usually apply to other 2000 x 5 x versions For an index with summaries and tables of calls grouped by functionality see Chapter 2 Note Commands that change Crystal Ball data cells will not run ifthe cell or the entire worksheet is write protected For example two such commands are CB Simulation and CB CellPrefsND You can use CB WorksheetProtection to unprotect and reprotect worksheets CB AboutBox This subroutine displays the About Crystal Ball dialog with information about Crystal Ball CB AboutBox Example This example opens the About Crystal Ball dialog CB AboutBox 50 Crystal Ball Macro Calls CB AlertOnArgumentError Subtopics e CB AlertOnArgumentError Example e CB AlertOnArgumentEror Related Calls This subroutine displays a message when the value ofa subroutine or function argument differs from what is expected Table3 CB AlertOnArgumentError Parameter Parameter VBA Data Type Description turnon Boolean True displays an alert message when an argument error occurs False switches off this alert The default is True CB AlertOnArgumentError Example This example switches off alerts when argument errors occur CB Aler
78. of fit report is produced When set to True this is the same as checking Show All Goodness of Fit statistics on the Output Options panel of the Batch Fit wizard cbBftFitDistLockParam 23 Used with va1ue1 Value2 Value3 and Valuea4 to specify which parameter to lock and which value to use cbBftFitDistLockParamClear 24 Used with Value1 and Value2 to specify which parameter to clear cbBftOutputOrientation 30 Used with va1ue1 to specify whether output is in rows or columns cbBftOutputSheetName 31 Specifies the name of the worksheet containing primary fit results assumptions as the string given for Value1 Table 11 CB BatchFitND Value1 Parameter Optional Variant Related Value For Index 1 cbBftlnputRange Named Constant Value A cell reference with VBA Data Type Index Value Description Variant n a Specifies the range of data to use for format fitting Range A1 C300 or A1 C300 For Index 2 cbBftInputRows Integer 1 Indicates that data cells are in rows cbBftInputOrientation For Index 2 cbBftInputColumns Integer 2 Indicates that data cells are in columns cbBftInputOrientation For Index 3 cbBftlnputHeader True or False Boolean n a Indicates whether the data range has headers If set to True there is header text in the top row or first column depending on the cbBftInputOrientation setting For Index 4 cbBftlnputLabel True or False Boolean n a Indicates wh
79. of suppressing forecast windows and minimizing worksheets and Microsoft Excel are set to True This call does not set a text string to use in the Microsoft Excel status bar since Microsoft Excel is minimized during the simulation and any string would never be displayed CB ResetND CB RunPrefsND cbRunMode cbRunNormalSpeed CB Simulation 100000 True True True TB Simulation 239 CB Simulation Related Calls Name Description CB Reset Resets the current simulation after prompting CB ResetND Resets the current simulation without confirmation CB StartMultiSimul Marks the start of multiple simulations CB StopMultiSimul Marks the end of multiple simulations CB SingleStep This subroutine runs one trial of a simulation changing the assumptions once The simulation must not be running when you use CB SingleStep CB SingleStep Example This example resets any previously run simulation and single steps once runs one trial The following call makes sure the trials begin at 1 CB ResetND CB SingleStep CB SingleStep Related Call Name Description CB Simulation Runs simulation for specified number of iterations CB StartMultiSimul This subroutine enables you to use resources more effectively when running multiple simulations using CB Simulation It calls CheckData on the first simulation and then increments the iterations counter at the start of each simulation If you call CB StartMultiSi
80. of the Run Preferences dialog and then clicking the Options button When set to False simulations in Microsoft Excel 2007 or later might run more slowly than if the preference were set to True the default CB GetExcel2007ForegroundMode CB GetExcel2007ForegroundMode Related Calls Name Description CB SetExcel2007ForegroundMode Sets the Run Preferences foreground mode setting for Microsoft Excel 2007 or later in Normal speed CB GetFitFilter This function returns the current value of the specified distribution fitting filter setting Table 123 CB GetFitFilter Returned Data Type Returned Value Returned Data Type The value of the current distribution fitting filter setting specified by Index Variant CB GetFitFilter has one parameter Index an integer The Index parameter specifies which distribution fitting filter parameter value to return Table 124 CB GetFitFilter Index Parameter Values Required Integer on page 170 Table 124 CB GetFitFilter Index Parameter Values Required Integer Named Constant Value Index Value Description cbFitFilterUse 1 Indicates if filtering is in effect True cbFitFilterlnside 2 Returns which input values are discarded in filtering True discards values inside the filtering range False discards values outside the range cbFitFilterFrom 3 Returns the lower bound of the filtering range cbFitFilterTo 4 Returns the upper bound of the filtering ra
81. or calculate values from existing correlations False the default CB RunPrefsND Example 1 This example sets the simulation to use the same sequence of random numbers with an initial seed value of 888 and use Monte Carlo simulation It then runs the simulation of 100 trials CB RunPrefsND cbRunSameRandoms CB RunPrefsND cbRunSamplingMethod CB Simulation 100 True 888 cbSamMonteCarlo CB RunPrefsND Example 2 This example shows how to use Index 62 cbRunAlertLevel Set Crystal Ball to show only important alerts CB RunPrefsND cbRunAlertLevel Set Crystal Ball to show all alerts Do not show again alert dialog checkboxes CB RunPrefsND cbRunAlertLevel 208 Crystal Ball Macro Calls and reset all cbRunAlertShowImportant cbRunAlertShowAll True CB RunPrefsND Related Calls Name Description CB GetRunPrefs Returns a run preference setting CB RunPrefs Changes run preference settings using a dialog CB RuntimeMode This subroutine turns off the Crystal Ball toolbar and menus so you can create applications with your own custom interface for novice Crystal Ball users These custom applications can be written with the Crystal Ball Developer Kit to run on Crystal Ball version 7 2 2 or later including 11 x or later You can give users the ability to run reset and single step through simulations by creating your own user interface controls with Visual Basic or VBA that call appropriate
82. series forecast using a dialog CB ExtractDataND Extracts data from the current simulation and restored results optimization or time series forecast without a dialog CB CreateRptND This subroutine sets report preferences and creates a Crystal Ball report For any preferences not manually set the default is the current setting in the Create Report dialog Use CB CheckData before using this call Note Although Full is the default report type in the Create Report dialog Custom cbRptCustom is the default report for CB CreateRptND To create a custom report call CB CreateRptND as follows before creating the report CB CreateRptND cbRptDefinedType cbRptCustom Table 32 CB CreateRptND Parameters Parameter VBA Data Type Description Index Integer Specifies which report preference you are setting See Table 33 Valuei Optional Variant Specifies settings for the preference indicated by Index See Table 33 Value2 Optional Variant Specifies settings for the preference indicated by Index See Table 33 Table 33 shows each Index value and the corresponding Value1 and Value2 parameter values Table 33 Index and corresponding Value1 and Value2 Parameters Index Named Constant Value Value CbRptOK 1 Description Generates the report Use this parameter after setting other report options Value1 Optional n a Value2 Optional n a 92 Crystal Ball Macro Calls Index
83. simulation is reset according to Valuel cbRunUserMacros 51 Specifies whether or not to run user defined macros according to va1ue1 cbRunCapMetrics 52 Sets whether the UI should display capability metric related information according to Valuel CB RunPrefsND 205 Index Named Constant Value Value Description cbRunCapMetricsShort 53 Determines if the underlying forecast data should be considered short or long term according to Valuel cbRunCapMetricsShift 54 Sets the shift value used for calculating Zst and Zlt according to Value1 cbRunCapMetricsCalcType 55 Determines if the metrics should be calculated from the fitted curve or the data according to Valuel cbRunCapMetricsNormalityThresh 56 Specifies the p value threshold used for normality testing according to va1ue1 cbRunCapMetricsNormalCalcOptions 57 Specifies whether to calculate the data from the fitted curve or the data if the forecast values are not normal according to va1ue1 only valid if cbRunCapMetricsCalcType O cbRunAlertLevel 62 Specifies which Crystal Ball alert messages to show according to va1ue1 optionally clears all Do Not Show Again preferences to default values if Value2 True Value2 default False cbRunAssumeZerosForUnspecifiedCorrs 65 Supports the Assume zeros for unspecified correlations run preference specifies whether to assume zeros for unspecified correlations True or calculate them from other values False the defau
84. software or related documentation that is delivered to the U S Government or anyone licensing it on behalf of the U S Government the following notice is applicable U S GOVERNMENT END USERS Oracle programs including any operating system integrated software any programs installed on the hardware and or documentation delivered to U S Government end users are commercial computer software pursuant to the applicable Federal Acquisition Regulation and agency specific supplemental regulations As such use duplication disclosure modification and adaptation of the programs including any operating system integrated software any programs installed on the hardware and or documentation shall be subject to license terms and license restrictions applicable to the programs No other rights are granted to the U S Government This software or hardware is developed for general use in a variety of information management applications It is not developed or intended for use in any inherently dangerous applications including applications that may create a risk of personal injury If you use this software or hardware in dangerous applications then you shall be responsible to take all appropriate fail safe backup redundancy and other measures to ensure its safe use Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications This software or hardware and document
85. subsequent sensitivity chart calls If this call is used and a simulation has not been run the macro returns error 5009 CB SensPrefs Example This example runs a simulation with 1000 trials either creates a sensitivity chart selects a single sensitivity chart or opens a chooser dialog if there are multiple sensitivity charts and then opens the Sensitivity Preferences dialog for the selected sensitivity chart CB Simulation 1000 CB SensPrefs CB SelectFore 221 CB SensPrefs Related Call Name CB SensPrefsND Description Sets preferences for the specified sensitivity chart without using a dialog CB SensPrefsND The function sets preferences for the selected sensitivity chart without using a dialog If more than one sensitivity chart is open and no chart is selected this call returns a cbErrNoSelection error for CB MacroResult Table 175 Parameters for CB SensPrefsND Parameter VBA Data Type Value Description Index Integer See Table 176 Works with optional parameters Value1 and Value2 to set sensitivity chart preferences Value1 Optional Variant See Table 177 Works with the Index parameter to set sensitivity chart preferences Value2 Optional Variant See Table 178 Works with Index 5 or 6 to set the maximum or minimum number of sensitivity values Table 176 following lists named constant and index values for the Index parameter Table 176 CB SensPrefsND Index Parameter
86. to 200 test whether the Weibull and gamma distributions have parameter locking switched on and finally return the current values set for the Location parameters of the Weibull and gamma distributions Dim LockVal as Double Dim UseLock as boolean Set the Weibull Location parameter to 250 for locking purposes and lock Hit cb LockFitParm cbDfaWeibull True 1 250 Set the gamma Location parameter to 200 for locking purposes but do not lock it cb LockFitParm cbDfaGamma False 1 200 Test if the Weibull distribution has parameter locking switched on returns True UseLock CB GetLockFitParm cbDfaWeibull Test if the gamma distribution has parameter locking switched on returns False UseLock CB GetLockFitParm cbDfaGamma Find the value set for the Weibull Location parameter returns 250 LockVal CB GetLockFitParm cbDfaWeibull 1 Find the value set for the gamma Location parameter returns 200 LockVal CB GetLockFitParm cbDfaGamma 1 CB GetLockFitParm Related Calls Name Description CB Fit Fits a specific probability distribution to a selected set of data range of cells CB GetFitParm Returns the value of the specified distribution parameter for the last CB Fit call CB LockFitParm Sets parameter locking for distributions and optionally specific parameters CB SetFitRange Specifies the data range to be used as input for CB Fit CB GetRunPrefs This function returns run prefere
87. two of Min Max and Certainty If you specify all three Crystal Ball uses Minand Maxto determine the certainty and ignores the entered Certainty value If Min or Max is set to a value other than Infinity or Infinity the certainty grabber is locked at the indicated value If either Min or Max is set to Infinity or Infinity the certainty grabber is not locked there CB SetRange Example 1 This example runs a simulation of 1000 trials selects cell B7 sets the certainty range to 5196 and applies it only to the forecast in cell B7 CB Simulation 1000 Range B7 Select CB SetRange 51 CB SetRange Example 2 This example runs a simulation of 1500 trials sets the certainty range to between negative infinity and 1000 and applies this certainty range to all forecasts CB Simulation 1500 CB SetRange cbMinusInfinity 1000 True 236 Crystal Ball Macro Calls CB SetRange Related Call Name Description CB Simulation Runs a Crystal Ball simulation CB Shutdown If Crystal Ball is loaded into Microsoft Excel this function closes Crystal Ball without closing Microsoft Excel It returns True when Crystal Ball is successfully unloaded Caution To avoid unexpected results do not unload Crystal Ball while other COM add ins are loaded in Microsoft Excel Table 200 CB Shutdown Returned Data Type Returned Value Returned Data Type The current Crystal Ball load status Boolean CB Shutdown Examp
88. two such commands are CB Simulation and CB CellPrefsND You can use CB WorksheetProtection to unprotect and reprotect worksheets so certain commands such as CB Simulation will run For more information on CB WorksheetProtection see CB WorksheetProtection on page 250 Putting Custom Applications into Runtime Mode If you ever want to deliver an application to someone who has Crystal Ball but is not a skilled user use the CB Runt imeMode call to hide the Crystal Ball user interface Then you can substitute your own controls created with Visual Basic or VBA to activate Crystal Ball features using Crystal Ball Developer Kit calls Your application can use any of the Crystal Ball features accessible through the Developer Kit You can also include Predictor time series analyses in your applications and users can run simulations in Extreme speed if it is available to them with Crystal Ball Decision Optimizer For details see Chapter 5 Crystal Ball Runtime Alphabetic List of Crystal Ball Macro Calls Note Full descriptions are listed alphabetically in Chapter 3 in the indicated sections 32 Crystal Ball Developer Kit Overview Table 1 Alphabetic List of Crystal Ball Macro Calls Name CB AboutBox on page 50 Description Displays information about Crystal Ball CB AlertOnArgumentError on page 51 Displays a message when an argument error occurs CB AlertOnMacroResultError on page 51 Displays
89. use with Predictor to perform time series forecasts It isa COM Component Object Model object which allows the use of older languages that support ActiveX objects such as Visual Basic 6 0 VB6 C VBA and others About the Predictor Developer Kit 293 Who Should Use This Kit The Predictor Developer Kit is appropriate for advanced users who want to automate repetitive spreadsheet time series forecasts This documentation assumes that readers are familiar with a COM compatible development platform and Crystal Ball with Predictor What This Kit Includes In addition to this Developer s Guide the Predictor Developer Kit includes the following files available in the specified folders under the Crystal Ball installation folder by default C Program Files Oracle Crystal Ball e CBCOMDevkKit tlb in the Bin folder accessible directly and through CBDevKit xla in the Crystal Ball installation folder e Toledo Gas xls in the Examples folder a sample spreadsheet with commented code so you can follow how the Predictor Developer Kit was used to create several sample time series forecasts e CBCom Devkit chm in the Docs folder an online help file that describes the methods and properties within each class of the Predictor Developer Kit see CB Com Devkit chm on page 282 for more information Developer Kit Use and Structure This section gives specific requirements for installing and using the Predictor Developer Kit It als
90. use your custom application Typically Crystal Ball Runtime applications are delivered as xls or xla files These are then combined for example zipped with the Crystal Ball setup file for the version of Crystal Ball used to develop the Runtime application for delivery to application users You also need to include an installation script to run the setup file and a licensing script to pass the appropriate license serial number to the Crystal Ball License Manager Alternately you can have application users unzip the application and Crystal Ball setup file double click the setup file to launch it and install Crystal Ball and then run the Crystal Ball License Manager to license Crystal Ball using the license serial number provided for each user Instructions are the same as those given in the current Crystal Ball Installation and Licensing Guide Note Users of Crystal Ball Runtime applications must meet the usual Crystal Ball system requirements For more information see System Requirements and NET on page 273 Installation Script The application setup script should include this command setup exe s v qn norestart lv c install log where e setup exe is the executable for the appropriateCrystal Ball installer If you downloaded your version of Crystal Ball from the Web the filename can include the version number such as cb111 exe and that name should appear in the script e s silent mode e v pass arguments
91. whether a distribution and optionally specific parameters have locked values for fitting purposes CB GetRunPrefs on page 181 Returns a Run Preferences setting CB GetScenarioAnalysisOption on page 182 Returns current settings for the Scenario Analysis tool CB GetTwoDSimulationOption on page 184 Returns current settings for the 2D Simulation tool CB GetVersion on page 187 Returns the current Crystal Ball version as a full build number or version ID number CB GetWorksheetVersion on page 188 Returns the Crystal Ball data version of the active or specified worksheet CB IsCBObject on page 189 Tests if a worksheet or workbook contains Crystal Ball data CB Iterations on page 190 Returns the number of trials run in a simulation CB LockFitParm on page 191 Sets parameter locking for distributions and optionally specific parameters CB MacroResult on page 192 Tells you if a Crystal Ball macro call worked correctly CB MacroResultDetail on page 194 Similar to CB MacroResult with additional error information CB OpenChart on page 196 Opens the selected chart of the specified type CB OpenFore on page 197 Opens a forecast window for the selected cell CB OpenSelection on page 198 Opens all charts defined for cells in the selected range CB OpenSensitiv on page 198 Opens the selected sensitivity chart CB
92. without displaying dialogs CB GetVersion This function returns the version ID or build number of Crystal Ball Optional parameters VersionType and Index determine what is returned and how much of it appears Table 149 CB GetVersion Returned Data Type Returned Value Returned Data Type The version ID number or build number of Crystal Ball as a string Variant Table 150 CB GetVersion Parameters VBA Data Parameter Type Value or Named Constant Index Description VersionType Variant A constant as specified in the n a n a Optional following two rows if O or unspecified the Crystal Ball version ID is returned as a string equivalent to cbProductVersion VersionType Variant cbProductVersion 0 Returns all or part of the Crystal Ball version ID for Optional example 11 1 1 1 00 can be used with Index to return only a portion of the version ID CB GetVersion 187 VBA Data Parameter Type Value or Named Constant Index Description VersionType Variant cbFullBuildVersion 1 Returns all or part of the Crystal Ball build number for Optional example 11 1 159 0 can be used with Index to return only a portion of the build number Index Optional Integer An integer from 1 to the number n a Returns the specified portion of the version ID or build of sections in the string returned by VersionType number counting from left to right If Index 3 159 would be returned fo
93. your use For installation instructions see the current Crystal Ball Installation and Licensing Guide Microsoft NET Framework Version The OptQuest Developer Kit has been tested to run properly with Microsoft NET Framework Versions 2 0 3 0 and 3 5 You can force the OptQuest Developer Kit to run against a specific 218 Using the OptQuest Developer Kit version of the NET Framework using an application configuration file in the form of lt appname gt exe config placed in the folder of the application s executable The following section forces the OptQuest Developer Kit code to run against Microsoft NET Framework 2 0 lt configuration gt lt startup gt lt supportedRuntime version v2 0 50727 gt lt startup gt lt configuration gt You might also want to run against a specific version of Microsoft Excel In that case appname would be excel and you would be modifying a file called excel exe config OptQuest Developer Kit Namespace The OptQuest Developer Kit contains the following main namespace in Visual Basic code Decisioneering CB CBCOMDevKit This namespace contains the classes required to set up and run an optimization with the OptQuest Developer Kit Important OptQuest Classes Two categories of important classes in the OptQuest Developer Kit e Optimization Setup Classes on page 279 e Optimization Runtime Classes on page 280 For lists and descriptions of methods and properties in these
94. 10 40 Net Income cbDecVarTypeCustom 10 20 30 40 Note that the data string the customData parameter can also be a valid cell range If the data string in the previous code is stored in range A1 D1 the code becomes Range G8 Select CB DefineDecVarND 10 40 Net Income cbDecVarTypeCustom A1 D1 122 Crystal Ball Macro Calls CB DefineDecVarND Related Calls Name Description CB DefineDecVar Defines or changes the decision variable in a selected cell using a dialog CB GetDecVar Retrieves information for a specific decision variable cell CB SetDecVar Changes certain attributes for a decision variable CB DefineFore This subroutine opens the Define Forecast dialog to create a new forecast or change an existing forecast in the selected cell The selected cell can be a simple value or formula cell You cannot define a forecast in a cell with an assumption Note Before calling this subroutine select a cell or cell range CB DefineFore Example This example opens the Define Forecast dialog so you can define or redefine a forecast Range B5 Select CB DefineFore CB DefineFore Related Calls Name Description CB GetFore Retrieves information for a specific forecast cell CB SetFore Changes forecast attributes without redefining the forecast CB DefineForeND This subroutine defines or changes a forecast in the selected cell without using a dialog The selected cell must co
95. 1ue1 to specify the maximum number of uncertainty simulations to display in the output report and overlay chart CB TwoDSimulationND 247 Named Constant Value Index cbTwoDRun 9 Description Runs the 2D Simulation tool Table 212 CB TwoDSimulationND Value1 Parameter Optional Integer Related Value Value or Named Constant Index Description For Index 2 cbTwoDAddAssumUncert 1 Used with coTwoDChooseAssum to add the selected cbTwoDChooseAssum Integer assumption to the uncertainty simulation For Index 2 cbTwoDAddAssumVar 2 Used with coTwoDChooseAssum to add the selected cbTwoDChooseAssum Integer assumption to the variability simulation For Index 2 cbTwoDAssumClearList 3 Used with cbTwoDChooseAssum to return all unfrozen cbTwoDChooseAssum Integer assumptions back to the uncertainty simulation For Index 3 Positive whole number integer n a Used with cbTwoDOuterSimTrials to specify the number cbTwoDOuterSimTrials of trials in the outer uncertainty simulation For Index 4 Positive whole number integer n a Used with cbTwoDInnerSimTrials to specify the number cbTwoDInnerSimTrials of trials in the inner variability simulation For Index 5 cbTwoDShowDefineFore 1 Uses display settings for each forecast chart the cbTwoDForeOption Integer equivalent of the Show Forecasts As Defined dialog setting For Index 5 cbTwoDShowTargetFore 2 Shows only the targ
96. 22 Enters a target value for the forecast according to Value Note Index cbForWindowsSize 3 is obsolete and is not included here Table 198 following describes the Value parameter CB SetFore 233 Table 198 CB SetFore Value Parameter Values Required Variant Used With Specified Values of Index For Index 1 cbForName String Value Forecast name in quotes Description Specifies the new forecast name For Index 2 cbForUnits String Units name in quotes Specifies the new units For Index 4 cbForAutoOpen Boolean True or False True displays the window automatically False does not For Index 5 cbForOpenWhen Integer O or 1 coOpnWhenRunning O cbOpnWhenStopped 1 Sets when to display the forecast chart 0 during the simulation 1 after the simulation stops For Index 6 cbForPrecision Boolean True or False True turns on precision control False turns it off For Index 7 cbForPrecisionAbsolute Boolean True or False True sets the confidence interval to be in absolute units False sets it in relative terms For Index 8 cbForPrecisionAbsoluteValue Units Sets the size of the confidence interval in terms Double of forecast units For Index 9 cbForPrecisionRelativeValue 0 01 to 99 99 Sets the size of the confidence interval in Double relative percentage terms For Index 10 cbForPrecisionMean Boolean True or
97. 2Best 4 cbPredictorMethods3Best 5 A tenth integer is available for cbRptSectionOrder the cbRptSectPredictorSeries section is assigned number 10 A new constant cbRptIncludeUnspecifiedCorrs 51 is added in 11 1 2 3 500 to support the Include unspecified correlations report preference CB DefineAltParms An optional fourth parameter is added to support the version of the beta distribution used in versions later than Crystal Ball 2000 5 5 5 cbParmMidpoint 20 and cbParmDegFreedom 21 are added to support the Student s t distribution added in Crystal Ball 7 0 Log and geometric mean and standard deviation alternate parameter sets can now be used with lognormal distributions Note Because there are three alternate parameter sets in addition to percentiles for the lognormal distribution the cbParmRegular named constant cannot be passed to CB DefineAltParms when setting up an alternate parameter set for the lognormal distribution You must explicitly set the parameter set with for example cbParmLogMean and cbParmLogStDev cbParmMode 15 is included to support the Extreme Value distribution for backward compatibility with Crystal Ball 2000 x 5 x In later versions of Crystal Ball that distribution is replaced with the Maximum Extreme and Minimum Extreme distributions cbParmMode is deprecated in this version of Crystal Ball and are obsolete in a future version Changes to Existing Calls 261 The implementation of
98. 9 262 CB DefineDecVarND 120 262 CB DefineFore 123 CB DefineForeND 123 263 CB DeleteChart 125 CB EnumAssum 126 263 CB EnumChart 127 CB EnumCorrelation 128 CB EnumDecVar 130 263 CB EnumFore 131 263 CB ExtractData 133 CB ExtractDataND 133 263 CB Fit 139 264 CB FormatPrefs 144 CB FormatPrefsND 145 CB Freeze 147 265 CB FreezeND 147 265 CB GetAsmSensitivityChartGroup 149 CB GetAssum 150 265 CB GetAssumEN 150 CB GetAssumPercent 152 265 CB GetAssumPercentFN 152 CB GetAssumStat 154 CB GetAssumStatFN 154 CB GetBatchFitOption 155 265 CB GetCBAutoLoad 160 CB GetCertainty 161 265 CB GetCertaintyEN 161 CB GetCorrelation 162 265 CB GetCorrelationByRef 163 CB GetDataAnalysisOption 164 CB GetDecisionTableOption 166 CB GetDecVar 168 266 CB GetFitFilter 170 CB GetFitParm 171 266 CB GetFore 173 266 CB GetForeData 175 CB GetForePercent 176 CB GetForePercentFN 176 CB GetForeStat 177 266 300 Index G L M N OP R S TU VW CB GetForeStatFN 177 CB GetLockFitParm 180 CB GetMicrosoft Excel2007ForegroundMode 169 CB GetRunPrefs 181 267 CB GetRunPrefsFN 181 CB GetScenarioAnalysisOption 182 CB GetTwoDSimulationOption 184 CB GetVersion 187 267 CB GetWorksheetVersion 188 CB IsCBObject 189 267 CB Iterations 190 CB IterationsFN 190 CB LockFitParm 191 CB MacroResult 192 CB MacroResultDetail 194 CB ND 258 CB OpenChart 196 CB OpenFore 197 CB OpenSelection 198 CB O
99. 95 and 100 CB Simulation 1000 CB OpenTrend Range B7 Select CB TrendPrefsND cbTrdChooseFore cbChfClearList CB TrendPrefsND cbTrdChooseFore cbChfAdd CB TrendPrefsND cbTrdValueAxis cbValMinMaxDiv 0 1000 CB TrendPrefsND cbTrdCertaintyBands 0 25 50 95 100 CB TrendPrefsND Related Call Name Description CB TrendPrefs Opens the Trend Preferences dialog for the selected trend chart CB TwoDSimulation This call launches the 2D Simulation tool wizard This tool estimates risk by running an outer loop to simulate uncertainty values and then freezes the uncertainty values while it runs an inner loop of the whole model to simulate variability This process repeats for some small number of outer simulations providing a portrait of how a given forecast distribution varies due to the uncertainty Note Before calling CB TwoDSimulation reset the simulation CB TwoDSimulation Example This example resets the Crystal Ball simulation and opens the 2D Simulation wizard CB ResetND CB TwoDSimulation 246 Crystal Ball Macro Calls CB TwoDSimulation Related Calls Name CB TwoDSimulationND Description Runs the 2D Simulation tool without displaying dialogs CB GetTwoDSimulation Option Returns current settings for the 2D Simulation tool CB TwoDSimulationND The 2D Simulation tool helps evaluate risk by estimating the uncertainty and variability for a given forecast using two dimensional si
100. A AE epa 227 CSC BWarbookPHader Example cir 228 Contents xiii CB SetDecVar nes nae TP NUM m PE EINEN TER 228 iic dcl 4 000 MET 229 CB SetDecVar Example 2 didactica 229 CB SetDecVar Related Calls s MR 230 CB Set ce 2007 ForegroundMode MMM 230 CB SetExcel2007ForegroundMode Example 1 2s sede sada pueda e REA 230 CB SetExcel2007ForegroundMode Related Call o ooooomommomo oo 230 CB SetFitFilter ads need eae aas ae dAl CB SetFitFilter Example A 231 CB SetFitFilter Related Calls taaan tania 231 CB SetFitRange lt er sear bes xd wa ss 231 DI SOPUIREDUEE A 232 CB SetFitRange Related Call Pre 233 CBee ET rv 232 CD set Tore Peale Laud area dO EE Gog p de iae aei peret 235 CR sid c y RAR AA 235 CB SetFore Related Calls 2 2 25 A A EE I AT TE E 235 CE SelRalper risrrocrtas bas wane bas 235 Ba Example L disexexduibkeseexduthbessP rdePuser4dakhra udi e de CB SetRange Example2 KORR ORC VARA ORO AR ARA RC RC 236 CB SetRange Related Call ads aes 44 vr aed bas vas ad ae 287 gd ns noc MEM T ete oie eee ened ee een peewee ee i eh ES vrai Air 237 CP Shutdown Related Calls 2 44 224r d Pad edipa dtk o Epa itke 237 CB SimResult ee T EARL eus ees 2 237 CB ds MA 238 CR SimResult Related Calls 14 2
101. Accesses the options set by ScenarioAnalysisND or the Scenario Analysis tool wizard CB ScenarioAnalysisND Runs the Scenario Analysis tool without using dialogs CB ScenarioAnalysisND The Scenario Analysis tool runs a simulation and then sorts and matches all the resulting values of a target forecast with their corresponding assumption values Then you can investigate which combination of assumption values gives a particular result You can run Scenario Analysis on any Crystal Ball model with at least one assumption and forecast that are not frozen You select a target forecast to analyze and then the forecast s percentile or value range to examine The resulting table shows all the values for the target forecast in the designated range sorted along with the corresponding assumption values CB ScenarioAnalysisND runs the Scenario Analysis tool and displays results without using dialogs Table 170 CB ScenarioAnalysisND Parameters Parameter Required VBA Data Type Table Index Required Integer Table 171 CB ScenarioAnalysisND Index Parameter Required Integer on page 216 Valuel Optional Variant Table 172 CB ScenarioAnalysisND Value1 Parameter Optional Variant on page 217 Value2 Optional Variant Table 173 CB ScenarioAnalysisND Value2 Parameter Optional Variant on page 218 Table 171 CB ScenarioAnalysisND Index Parameter Required Integer VBA Data Index Named Constant Valu
102. BCOMDevKit OptRuntime class as a variable with events Private WithEvents PortfolioOptRuntime As CBCOMDevKit OptRuntime In this example the variable name PortfolioOptRuntime is declared as on OptRuntime class type Then declare other variables as required For more information see Coding an Optimization on page 285 Whenever you want to enter an event macro into your code go to the first drop down list in the code window and choose the name of the variable assigned to OptRuntime Available events are listed in the second dropdown list in the code window When you click one it is inserted into your code for that workbook as a private subroutine for example Private Sub PortfolioOptRuntime AfterlterationEvent IterationsCompleted As Long End Sub The subroutine takes the name of the variable assigned to OptRuntime followed by an underscore and the name of the selected event Any required and optional parameters appear in parentheses following the name You insert code as usual using any appropriate VBA code and macros from the Crystal Ball and OptQuest Developer Kits For example you can set cell values or perform other operations described elsewhere in this Overview document or the Crystal Ball Developer Kit User Manual Then when the selected event occurs the code runs Important Note In any event handler that modifies values or formulas within a Microsoft Excel workbook or calls functions that could modify values yo
103. BL sed on a percentile range cbSceSelectPercentiles the 50th percentile to the 75th 50 75 for the target forecast while the tool is running cbSceShowTarget Fore D cbSceForeOption 500 arget forecast in the results False D cbSceRun CB ScenarioAnalysisND Related Calls Name Description CB GetScenarioAnalysisOption Accesses the options set by ScenarioAnalysisND or the Scenario Analysis tool wizard CB ScenarioAnalysis Opens the Scenario Analysis tool wizard CB SelectAssum This subroutine selects all assumptions in the current worksheet The desired worksheet must be active selected for Crystal Ball to run this command CB SelectAssum Example This example activates the Model worksheet of the Futura with OptQuest xls workbook and selects all the assumptions in the worksheet Workbooks Futura with OptQuest xls Worksheets Model Activate CB SelectAssum CB SelectAssum Related Calls Name Description CB SelectDecVar Selects all decision variables in the current worksheet CB SelectFore Selects all forecasts in the current worksheet CB SelectChart This call selects or activates the current operating chart If the specified name is not found an error is thrown If a name is not specified for example by passing an empty string as the name and more than one chart of the specified type is found a chooser dialog appears Currently this call only works on curre
104. CB CheckData CB CreateRptND cbRptChooseAssum cbChaClearList CB CreateRptND cbRptChooseAssum cbChaChosen Range B5 Select CB CreateRptND cbRptChooseAssum cbChaAdd CB CreateRptND cbRptChooseAssum cbChaChosen Cb CreateRptND cbRptAssumParam True CB CreateRptND cbRptOK CB CreateRptND Related Calls Name Description CB CreateRpt Sets report preferences and creates a report from the current simulation and restored results optimization or time series forecast using a dialog CB ExtractData Extracts data from the current simulation and restored results optimization or time series forecast using a dialog CB ExtractDataND Extracts data from the current simulation and restored results optimization or time series forecast without a dialog CB DataAnalysis This call launches the Data Analysis tool wizard This tool helps you import data directly into Crystal Ball forecasts for further analysis Note Before calling CB DataAnalysis reset the simulation CB DataAnalysis 101 CB DataAnalysis Example This example resets the Crystal Ball simulation and opens the Data Analysis wizard CB ResetND CB DataAnalysis CB DataAnalysis Related Calls Name Description CB GetDataAnalysisOption Returns current settings for the Data Analysis tool CB DataAnalysisND Imports data into Crystal Ball forecasts without using a dialog CB DataAnalysisND The Data Analysis tool imports data directly int
105. CB DefineAltParms Related Calls T TT T ones s 112 KD DICE e E Roeaub uco Ro oC CER oe 10 E uw FO dud CER e dw s ere 112 sh te au ciae Dux XAR de OCC ER PRECII GARE RR zx 112 CB Dehne ssum Example 2 voor AAA ERROR E ACE RR AG 112 CB DefineAssum Related Calls bees dabas 112 CB DefineAssumND A MEM ERU ESSI CE aa 113 LB DehneAssumND Example scrape arre 116 CB DefineAssumND Example 2 aba wd dnd 116 Defining Cusen DOS 4 591449 4 eredu iter ioei x FERYWRRS ie 116 CB DefineAssumND Custom Distribution Example o ooooooommmo o 117 CH DenneAssimND Related Calls coc cr ai 117 RN a AAA O quae doe LIF CE DefineAssum rom POre ND Ecler RARA ARE 118 CB DefineAssumFromForeND Related Calls oooooooooooooo o 119 CB DefineDecVar TS Shee pus bad eer TM gas bas T pus mi CBLDEDREDCUA Example cirio edd 199 LR DefimneDecVar Related Calls aaa TS ELS CB DefineDecVarND Ia6 CE Denne ec ae BESUDBOT rior rd p oper CROIRE HC eed GB Denne DaN Ee ugue ex qe bees eae Ra CX Qe PESE ENS AS 121 CA DefineDec ain Exenple3 rra AA EAE e a 122 CB DefineDecVarND Example 4 dus beg TER TET 122 CD Denne VIENDO Eramiple Sins hei bee AA Ede Es m CB DelneDecVarND Related Calls aides esa dassduer eek FR RE CERE RE 123 CB DefineFore er ee S poe Bode M EE bd ERO m T a123 CE Deme or ERN 4 u
106. CapMetricsNormalCalcOptions 57 New constant coRunAssumeZerosForUnspecifiedCorrs 65 is added in 11 1 2 3 500 e cbRunPrecisionMean 41 used in versions before Crystal Ball 2000 5 5 5 is now obsolete e The equivalent Valuel and Value 2 constants are removed or added as appropriate e Starting with Crystal Ball 11 1 2 1 000 cbRunAlertLevel 62 and related constants are added to specify the level of alert messages to show and to reset message display preferences CB SensPrefsND e cbSenIncludeAssum 3 is now obsolete coSenChooseAssum 8 is used in its place e cbSenIncludeOtherFore 4 is now obsolete 268 Changes from Previous Versions e cbSenTitle 7 has been added CB SetAssum e Data type returned changes from boolean to Variant e The first parameter name is changed from AssumRef to AssumReference to correct a documentation error e The data type of the first parameter is changed from Range to Variant CB SetDecVar e Data type returned changes from boolean to Variant e The first parameter name is changed from DecVarRef to DecVarReference to correct a documentation error e The data type of the first parameter is changed from Range to Variant e There is a new Index constant cbDecFrozen 6 e Starting with Crystal Ball 11 1 1 0 00 two new Index constants are added o cbDecType 4 with Value constants cbDecVarTypeContinuous 0 cbDecVarTypeDiscrete 1 cbDecVarTypeBinary 2 cbDecVarTypeCategory
107. Crystal Ball 2000 5 5 5 CB ExtractDataND has changed to support the new functionality o The Value constant cbDatForeValues 1 is deprecated in this release cbDatValues 1 should be used instead o The description of Value constant cbChfChosen 3 corrects a documentation error Use this constant after cbChfAdd not cbChaAdd o The Value constant cbDatCumulative 5 is not included in this release o Anew Valueconstant cbDatCapMetrics 7 is added for Index constant cbExtDataType 2 o Value constants cbPctSet3 7 and cbPctSet4 8 are added to support new product functionality Changes to Existing Calls 263 o For Index constant cbExtExistingSheet 5 Value constants can be cbOKExistingSheet or cbOKNewSheet as well as True or False respectively o Additional Index constants are added cbExtChooseAsm 6 cbExtChartBins 7 and cbExtIncludeCellLoc 8 Crystal Ball 7 2 plus cbExtIncludeLabels 9 cbExtAutoFormat 10 cbExtSheetName 11 cbExtStartCell 12 and cbExtStartSheet 13 Crystal Ball 7 2 1 o Starting with Crystal Ball 11 1 2 0 00 a new constant cbExtChartBinsUseEntireRange 28 is added to the Index parameter to indicate whether to display all values including extreme values that are not displayed in the chart or just the values displayed in the chart For more information on these constants and other changes see Table 69 To support the rewritten version of OptQuest added in version 11 1 1 0 00 o
108. Distribution is True works with Value to specify a ranking method for distribution fitting See Table 80 for constants cbDataAnalysisGenerateCorrelationMatrix Integer 13 Uses a boolean value for the va1ue parameter to indicate whether rank correlations between forecast charts should be displayed in a matrix True generate matrix cbDataAnalysisRunOnAllModels Integer 14 Uses a boolean value for the Value parameter to indicate whether a simulation is run on all open workbooks at the same time the selected data is analyzed In this case forecast charts for all opened models appear with those generated from the data selected for analysis True run the simulation on all open workbooks this setting can be used for validating models cbDataAnalysisResetSessionVariable Integer 17 Resets all session variables related to the CB DataAnalysisND Developer Kit call including the input data series and the LSL USL and Target capability values CB DataAnalysisND 103 Table 46 CB DataAnalysisND Value Parameter Optional Variant VBA Data Index Related Value Named Constant Value Type Value Description For Index 2 A cell reference with Variant n a Specifies the numeric portion of cbDataAnalysisSelectData format Range A1 C300 or the data to be imported A1 C300 For Index 3 cbDataAnalysisDatalnRows Integer 1 Indicates that data cells are in cbDataAnalysisDataOrient
109. For Index 7 String Title in quotes n a Defines the sensitivity chart title For Index 8 Integer cbChaAll 1 Includes all assumptions For Index 8 Integer cbChaAdd 3 Adds the assumption in the selected cell to the list of chosen assumption For Index 8 Integer cbChaClearList 4 Clears the list of chosen assumptions For Index 8 Integer cbChaRemove 6 Removes the assumption in the selected cell from the list of chosen assumptions Table 178 following lists values for the optional Value2 parameter Table 178 CB SensPrefsND Value2 Parameter Values Optional Variant Used With Specified Values of Index For Index 5 Integer Value A positive whole number Description Sets the maximum number of sensitivities to display For Index 6 Double A positive number between 0 00 and 1 00 Sets the minimum sensitivity values to display CB SensPrefsND Example The following example runs a simulation selects cell B2 defines that cell as the target forecast for a sensitivity chart creates and names the sensitivity chart indicates the sensitivity should be shown as Contribution to Variance limits display to the four most sensitive assumptions with sensitivities greater than 0 1 and finally opens the chart CB Simulation 1000 Range B2 Select CB SensPrefsND cbSenTargetFore CB SensPrefsND cbSenTitle My Sensitivity Chart CB SensPrefsND cbSenMeasure cbMesContributionToVar CB Se
110. GetAsmSensitivityChartGroup Example For an example of this call see CB SetAsmSensitivityChartGroup Example on page 224 CB GetAsmSensitivityChartGroup Related Call Name Description CB SetAsmSensitivityChartGroup Assigns an assumption to a sensitivity chart group or removes an assumption from a group CB GetAssum This function retrieves information for a specific assumption cell You can call this function from either a subroutine or a worksheet Note To call this function from a worksheet use the name CB GetAssumEN Named constants do not work as arguments in worksheets You must use the index number instead Note that the CB GetAssum call is not retrieving the name and value of the third and fourth parameters properly for assumptions defined with alternate parameter sets of a beta distribution via CB DefineAltParms For best results call CB CheckData before calling this function to ensure the latest data values are used Table 88 CB GetAssum Returned Data Type Returned Value Returned Data Type Some attribute or parameter for the assumption Variant 150 Crystal Ball Macro Calls Table 89 CB GetAssum Parameters Parameter VBA Data Type Value Description AssumReference Variant In a macro Range B3 Points to the desired assumption cell In a worksheet B3 Index Integer See Table 90 Retrieves information for a specific assumption cell using constant and index values listed in Table 90
111. H Create Dat airada idque seed qEcsddbe RP SSE S pie didi 90 CB CreateChart Example Eres TR sa a has TT er sss ic reateC hart Welated Cale cita Ass Y d tW ll gai H t 91 CB CreateRpt Example pads i CLICR ROS UE uu ade d e oleo ap d RO dE RU de opea 1 ee CAIN i cassqd aa AA qe peces euer ii oa qid 92 CH Createhotn Example 222sasasdesuaehesdeza4cdegpaeeRee4REra4xks 100 CB CreateRptND Example2 dus beg ess ws spit s 101 Ae E QUIS AMA 101 CB D taAnalysi 2 222424 RES MERA d pd dde dede ed Se E od et TER 101 CB DataAnalysis Example ee dd s 102 CB DataAnalysis Related Calls cocos rera Crea ek ras VUE UBI DIEN ivi A AA ETE Eg 102 CB Data nalysii ND Example 142225 24422232 rr REA ER 105 CB DataAnalysisND Related Calls piss T eters T 106 CB Decision Table uos esee Ra NEM ENE EIU EE eer Peele 106 CB DecisionTable Example TT Rad a RC PE VR doa d EVER 106 CB DecisionTable Related Calls T ee ads 106 LB Deceit DIRE ra cere ys deb Rb ob de ode e EO depo del orden d TO CR Docson ORNO ENIPE cercos par rr a a eSt 108 CB Decision TableND Related Calls iiuquqaeekbeq szaechbt ra 108 ee AA 109 CB DefineAltParms Example 1 beds 111 CU Deen AN Pati ERR QUE apiid peo o e hae x edo E EORR dtd 111 Ce Dennen Pari Pace 654046254084 a 111
112. InputRange 1 Used with Valuez to select the location of the data series for fitting a range address string The range must be contiguous adjoining cells cbBftInputOrientation 2 Used with Value to specify whether the data cells are in rows or columns cbBftInputHeader 3 Used with Value to indicate whether the input range has headers If set to True there is header text in the top row or first column depending on the cbBftInputOrientation setting cbBftinputLabel 4 Used with va1ue1 to indicate whether the input range has labels If set to True there is label text in the first column or top row depending on the cbBftlnputOrientation setting cbBftSelectDist 5 Used with va1ue1 to choose a specific distribution to fit takes cbDfa distribution constant as specified in Table 78 cbBftSelectDistAll 6 Chooses all available continuous and discrete distributions to fit cbBftSelectDistClear 7 Clears all distributions currently selected for fitting cbBftSelectDistAllContinuous 8 Chooses all available continuous distributions to fit cbBftSelectDistAllDiscrete 9 Chooses all available discrete distributions to fit cbBftSelectDistAuto 10 Automatically chooses which distributions to fit cbBftRankMethod 11 Used with va1ue1 to choose a ranking method as listed in Table 80 cbBftOutputLocation 12 Used with va1ue1 to specify an output location in a new workbook cbBftOutputFormat 13 Used with Value1 to specify whether output is formatted If set to True it is fo
113. Kit in CBCOMDevkKit dll 2 Equation Property Version 11 1 1104 0 e DecEnumerator Class Decision Class Syntax E DecVarValue Type Enumeration Q amp VarEnumerator Interface ce Visual Basic Visual Basic Usage e Objective Class F ObjEnumerator Class Dim instance As Decision ObjReqBase Class ig OptCondition Type Enumeration B OptConstraint Type Enumeration e OptCounters Class Members ig OptDecisionType Enumeration E OptEFFBoundType Enumeration All Members Constructors 0 e OptEfficientFrontier Class 8 OptEFFSelection Type Enumeration 4 XNA Framework B OptEFF TestType Enumeration 2 Public Only xX e OptimizationEvents Interface a E OptimizationState Enumeration J Protected 4 Static Ss J Inherited pense ees E OptMoreLessCondition Enumeration 8 OptObjective Type Enumeration B OptOptimization Type Enumeration Q amp OptOptions Class Decision Default Decision variable constructor Decision Class J Instance J Declared Member Description E OptRunForType Enumeration Decision String String Decision variable constructor using cell address OptRuntime Class n BaseCase Decision variable step 8 OptRuntime AfterSimulationEventHandler Delegate ig OptRuntime EfficientFrontierEventHandler Delegate 3 OptRuntime OptEventHandler Delegate CustomValues A set of possible values for this Decision Variable If you click the Visual Basic tab Visual Basic appears i
114. List to clear the list or if you want to freeze the same list later leave it Then you can Freeze Unfreeze the same set of variables with CB FreezeND cbFrzSetList True CB FreezeND cbFrzSetList False respectively End Sub CB FreezeND Related Calls Name Description CB Freeze Defines which assumptions decision variables or forecasts to hold to their worksheet values during a simulation using a dialog CB Reset Resets a simulation after confirmation prompting CB ResetND Resets a simulation without confirmation prompting CB GetAsmSensitivityChartGroup This subroutine returns the group name for an assumption in a sensitivity chart assumption group or an empty string if the assumption is not included in a group Before you call this subroutine the assumption must exist CB GetAsmSensitivityChartGroup 149 Table 86 CB GetAsmSensitivityChartGroup Returned Data Type Returned Value Returned Data Type Name of the sensitivity chart group to which the specified assumption belongs String This subroutine has one required parameter Table 87 CB GetAsmSensitivityChartGroup Parameter Required Variant on page 150 Table 87 CB GetAsmSensitivityChartGroup Parameter Required Variant Parameter VBA Data Type Value Description AssumReference Variant In a macro Range B3 Specifies the cell of the assumption whose sensitivity group is to be returned CB
115. Note Before calling this subroutine reset the simulation and select a cell CB DefineAssum Example 1 This example selects cell B5 a single value cell with no defined assumption and then opens the Distribution Gallery so you can select a distribution for the assumption CB ResetND Range B5 Select CB DefineAssum CB DefineAssum Example 2 This example selects cell D5 previously defined as a uniform distribution assumption and then opens the Uniform Distribution dialog with the current parameter fields filled in You can change the parameters or select a different distribution by clicking Gallery CB ResetND Range D5 Select CB DefineAssum CB DefineAssum Related Calls Name Description CB CorrelateND Defines a correlation coefficient between two selected assumptions 112 Crystal Ball Macro Calls Name Description CB DefineAssumND Defines or modifies assumptions in selected cells without using a dialog CB GetAssum Retrieves information for a specific assumption cell CB SetAssum Modifies certain attributes for the assumption in a cell CB DefineAssumND This subroutine defines a new assumption or changes an existing assumption in the selected cell without using a dialog If a simulation runs before this subroutine is used the simulation must be reset before the assumption is defined Note Before calling this subroutine select a single cell Table 54 CB DefineAssumND Paramete
116. OpenTrend on page 199 Opens the selected trend chart CB PasteData on page 199 Pastes assumptions decision variables or forecasts into selected cells CB Reset on page 201 Resets the current simulation after prompting CB ResetND on page 201 Resets the current simulation without confirmation CB RestoreResults on page 202 Restores simulation results from a file using a dialog CB RestoreResultsND on page 203 Restores simulation results from a file without a dialog CB RunPrefs on page 204 Sets Crystal Ball run preferences using a dialog CB RunPrefsND on page 204 Sets Crystal Ball run preferences without a dialog CB RuntimeMode on page 209 Hides the Crystal Ball toolbar and menus CB SaveResults on page 210 Saves current simulation results using a dialog 36 Crystal Ball Developer Kit Overview Name CB SaveResultsND on page 210 Description Saves current simulation results without a dialog CB ScatterPrefs on page 211 Opens the Scatter Preferences dialog for the selected scatter chart CB ScatterPrefsND on page 212 Sets preferences for the specified scatter chart CB ScenarioAnalysis on page 215 Opens the Scenario Analysis tool wizard CB ScenarioAnalysisND on page 216 Runs the Scenario Analysis tool without using dialogs CB SelectAssum on page 219 Selects all assumptions in the curre
117. Oracle Crystal Ball Developer s Guide Release 11 1 2 3 500 ORACLE Crystal Ball Developer s Guide 11 1 2 3 500 Copyright 1988 2014 Oracle and or its affiliates All rights reserved Authors EPM Information Development Team Oracle and Java are registered trademarks of Oracle and or its affiliates Other names may be trademarks of their respective owners Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International Inc AMD Opteron the AMD logo and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices UNIX is a registered trademark of The Open Group This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws Except as expressly permitted in your license agreement or allowed by law you may not use copy reproduce translate broadcast modify license transmit distribute exhibit perform publish or display any part in any form or by any means Reverse engineering disassembly or decompilation of this software unless required by law for interoperability is prohibited The information contained herein is subject to change without notice and is not warranted to be error free If you find any errors please report them to us in writing If this is
118. Overview Name Description CB GetAssumStatFN Calculates the specified statistic for the assumption in the specified cell See CB GetAssumStat on page 154 CB GetCertaintyFN Returns the certainty level of achieving a forecast value at or smaller than a specific threshold See CB GetCertainty on page 161 CB GetForeDataFN Returns the value for the given trial for a specific forecast cell See CB GetForeData on page 175 CB GetForePercentFN Returns the value corresponding to a percentile for a specific forecast See CB GetForePercent on page 176 CB GetForeStatFN Returns statistic for a specific forecast cell See CB GetForeStat on page 177 CB GetRunPrefsFN Returns a Run Preference setting See CB GetRunPrefs on page 181 CB IterationsFN Returns the number of trials run in a simulation See CB Iterations on page 190 CB Spearman Calculates Spearman rank correlations between pairs of values See CB CalculateSpearman on page 67 Opening and Closing Crystal Ball The macro calls in this group can be used to e Load open and close Crystal Ball e Set Crystal Ball autoload defaults e Determine if Crystal Ball is loaded The following sections describe macro calls that are used to open and close Crystal Ball e CB CBLoaded on page 67 e CB GetCBAutoLoad on page 160 e CB SetCBAutoLoad on page 227 e CB Shutdown on page 237 e CB Startup on page 242
119. Runs before random numbers have been placed in assumption cells CBAfterRecalc Runs after Microsoft Excel has recalculated the model but before a trial value has been retrieved from the forecast cells CBAfterTrial Runs after the forecast trial values have been retrieved and entered into the forecast charts CBAfterSimulation Runs when the simulation is complete or stopped with a Stop command by single stepping after each step or for any other reason Crystal Ball Developer Kit Overview Note None of the Developer Kit macro calls can be used within user defined macros such as CBBeforeSimulation Figure 1 shows where each macro fits into the Crystal Ball simulation cycle Figure 1 When User Defined Macros Run d oi db Stina ence Sands lee hea CBBeforeSimulation IX DEI E CBBeforeTrial Set Values Recalculate ding Ses Glad ome eue Bus CBAfterRecalc Get Results CBAfterTrial CBAfterSimulation Crystal Ball searches for macros with these names in open workbooks and runs them at the appropriate points during the simulation The macros must be contained within workbooks and worksheets not VBA modules and Run User Defined Macros must be selected on the Options tab of the Run Preferences dialog Crystal Ball checks for the presence of any CBBeforeTrial CBAfterTrial and CBAfterRecalc macros before the simulation runs by attempting to execute them If this poses a problem you may skip the logic in the
120. SP altis 164p E dae DC Rie d CUR Ea PORC ERR 261 DOLO A he DOC Dk Ea ee tobac scien ee ea dees 262 CB DefineAssumND oreren uae a a sewn RA eax 262 CB DefineDecVar edd Boiss bes nis peak ee nee us ss 262 CE Dent Va ND a di dp Exam p buh pee qp deg bu kya d que eee sees 262 CB DelnePore ND 422232924 aasaequpaaeenqeqaueseuq equae qd quada 263 CB EnumAssum TEE errr o Edu Sore eee eee 263 A OE ioe oil A dx b Roe OE C De FA we OR CER ES 263 CRES Cau coss d a ed Pe eRe dea t ids Joa RAS 263 CD ExtractDataND iau sua ace ROCA AR AAA KORR MRS DRS 263 PP qu quic do coe ded dedo dec ole ul qao bot 264 CE ree and CD Pree on cee cote stEr xq RETO EVE PER Nd per ERE 265 CD GELASSWIM espro AE AAA ROI GR AER ERE aS 265 CB GetAssumPercent a s ee atus bep e peus bes OPES 265 EREE i In MM E a E E CD GPL IT e AAA A 265 CB GetCorrelation es an oes ae as ee pres da TET Ei es ee 265 L De SE wid hs a ps he aie RA A E T 266 CE OCPI aie oues a y ia a gr deu e dag at Sees 266 COS sicarios aras dpi 266 CB GetForeStat AS ee re eee PL ee bubo 266 Gee Oey a ak ek eai d AER EK Se th E dep 267 CB GetVersion CB GetWorksheetVersion 0 00 eee eee eee direi 267 CB IsCBObject dd Sad ps oe dd ee ss 267 Hi 24 xao det que dei ale UE qe quropa E orae qe R eae pop 267 LED oie Seuss sirine parana er KC C A dde wd seus 267 CUP ARM dod o e gipExddo d 267 CB RunPrefsND Rus er Aedes ee E pieds es aes
121. SUUCEMNE DUE aub MEM RE BR RUxK PME En DEUS 294 Developing Tire sSenes Forecasting Code ici i ad aad eae CUR REX PRO UHR ERA da 298 About the Predictor Developer Kit Note The Predictor Developer Kit described in this Developer s Guide is completely rewritten Developer kit code written for automating CB Predictor in Crystal Ball versions earlier than 11 1 1 3 00 is not compatible with the current version of Predictor or this Predictor Developer Kit Welcome to the Predictor Developer Kit for all Crystal Ball products You can use the Predictor Developer Kit to automate and control the setup and running of Predictor time series forecasts from within applications written for a variety of Microsoft COM compatible platforms This opens up a range of possibilities e Integrating Predictor with other software tools e Creating turnkey applications that shield users from program intricacies e Building custom reports or automating analysis when time series forecasts are complete e Setting up specialized time series forecast environments The Predictor Developer Kit provides a link between Predictor and your application It consists ofa number of object oriented development classes that control many aspects of Predictor Each Crystal Ball product comes enabled to use the Predictor Developer Kit so that applications you develop can be run by other users with appropriate licenses The Predictor Developer Kit provides a framework of classes that you can
122. Saveme cbr CB SaveResultsND Related Calls Name Description CB RestoreResults Restores simulation results from a file using a dialog CB RestoreResultsND Restores simulation results from a file without a dialog CB SaveResults Saves current simulation results using a dialog CB Simulation Runs a Crystal Ball simulation CB ScatterPrefs This call pens the Scatter Preferences dialog for the selected scatter chart either open or closed If more than one scatter chart is found this call opens a chooser dialog If no scatter chart has been defined this call creates a new chart with no selected assumptions or forecasts using the default preferences This chart then becomes the selected chart for subsequent scatter chart calls If this call is used and a simulation has not been run the macro returns error 5009 CB ScatterPrefs Example The first call in this example runs a simulation The second call either creates a scatter chart selects a single scatter chart or opens a chooser dialog if there are multiple scatter charts and then opens the Scatter Preferences dialog for the selected scatter chart CB ScatterPrefs 211 CB Simulation 1000 CB ScatterPrefs CB ScatterPrefs Related Call Name Description CB ScatterPrefsND Sets preferences for the specified scatter chart CB ScatterPrefsND This call sets preferences for the selected scatter chart If more than one scatter chart is open and no chart
123. Tools then References and select cbdevkit xla you might have to browse for it in the folder where Crystal Ball is installed Once you save your application file you should not have to do these steps again In Microsoft Excel 2007 or later display the Developer tab as described in step 1 of the previous directions Then select Visual Basic then Tools and then References and check cbdevkit xla Crystal Ball Runtime Licensing Requirements Crystal Ball and related products must be used in accordance with the applicable Oracle license agreement Crystal Ball Runtime Licensing Requirements 275 276 Crystal Ball Runtime Using the OptQuest Developer Kit In This Appendix About the DprOuest Developer Mit A emi siae ruga RUE adden 2I OptQuest Developer Kit Use and Structure cccceccccceeeeceeeeeeeeaeseeseeteeeaeenenenes 278 Developing Optimization Coda 222 ii ede ee Pee ee dd 282 User detined Event Macros tor Optimizations is soci corta dd ends 287 About the OptQuest Developer Kit Welcome to the OptQuest Developer Kit for Crystal Ball Decision Optimizer You can use the OptQuest Developer Kit to automate and control the setup and running of OptQuest optimizations from within programs written for a variety of Microsoft COM compatible platforms This opens up a range of possibilities e Integrating OptQuest with other software tools e Creating turnkey applications that shield users from program intricacies e Buildi
124. Type Value Description DecVarReference Variant In a macro Range B3 Points to the desired decision variable cell Index Integer See Table 121 Returns specified data from the selected decision variable using the constant and index values shown in Table 121 The following table shows named constant and index values for the Index parameter Table 121 CB GetDecVar Index Parameter Values Required Integer Named Constant Value Index Value Description cbDecName 1 Returns the decision variable name 168 Crystal Ball Macro Calls Named Constant Value Index Value Description cbDecMin 2 Returns the decision variable minimum lower bound cbDecMax 3 Returns the decision variable maximum upper bound cbDecType 4 Returns the type of decision variable 0 Continuous 1 Discrete 2 Binary 3 Category 4 Custom cbDecStep 5 For discrete variables this returns the step size cbDecFrozen 6 Returns whether the decision variable in the selected cell is frozen cbDecCustomData 7 Returns the custom value list or range if coDecType 4 Custom cbDecCustomDataCount 8 Returns the number of values in the custom value list or range if coDecType 4 Custom CB GetDecVar Example This example puts all the decision variable information for the decision variable in cell B3 into cells F2 through F9 assuming that cbDecType 4 Custom In a macro you can enter For i 1 To 8 CB
125. Values Required Integer Named Constant Value Index Value Description cbSenTargetFore 1 Defines the selected forecast cell as the target forecast cbSenMeasure 2 Sets whetherto measure sensitivity by rank correlation or by contribution to variance according to Valuel cbSenDisplayOnlyHighest 5 Sets to display only the highest sensitivities according to va1ue1 and Value2 cbSenDisplayGreaterThan 6 Sets to display only sensitivities greater than va1ue2 according to Value1 cbSentitle Gives the sensitivity chart a title according to Value1 cbSenChooseAssum 8 Clears and selects the assumptions for the sensitivity chart according to va1ue1 Note Index values cbSenIncludeAssum 3 and cbSenIncludeOtherFore 4 are obsolete Table 177 following lists values for the optional Value1 parameter 222 Crystal Ball Macro Calls Table 177 CB SensPrefsND Value1 Parameter Values Optional Variant Used With Specified Values of Index Named Constant or Boolean Value Index Value Description For Index 2 Boolean True or False OR n a True measures sensitivity by rank correlation cbMesRankCorrelation or False uses contribution to variance cbMesContributionToVar For Index 5 Boolean True or False n a True displays only a certain number Va1ue2 of sensitivities False does not For Index 6 Boolean True or False n a True only displays sensitivities greater than Value2
126. Windows 41 CB CopySensitiv on page 85 CB CopyTrend on page 86 CB CreateChart on page 90 CB DeleteChart on page 125 CB EnumChart on page 127 CB SelectChart on page 219 Handling Crystal Ball Results The macro calls in this group can be used to Set the certainty range for forecasts Get assumption decision variable and forecast values statistics and percentiles Extract data Create reports Save and restore results The subroutines and functions described in the following sections are used to work with Crystal Ball results 42 CB CreateRpt on page 91 CB CreateRptND on page 92 CB ExtractData on page 133 CB ExtractDataND on page 133 CB GetAssum on page 150 CB GetAssumPercent on page 152 CB GetAssumStat on page 154 CB GetCertainty on page 161 CB GetCorrelation on page 162 CB GetCorrelationByRef on page 163 CB GetDecVar on page 168 CB GetFore on page 173 CB GetForeData on page 175 CB GetForePercent on page 176 CB GetForeStat on page 177 CB RestoreResults on page 202 CB RestoreResultsND on page 203 CB SaveResults on page 210 Crystal Ball Developer Kit Overview e CB SaveResultsND on page 210 e CB SetRange on page 235 e CB SimResult on page 237 Setting and Getting Preferences The macro calls in this group can be used to e Set run preferences e Set format pr
127. a dialog CB DefineDecVarND on page 120 Defines or changes a decision variable in a selected cell without a dialog CB DefineFore on page 123 Defines a forecast in a selected cell using a dialog CB DefineForeND on page 123 Defines a forecast in a selected cell without a dialog CB DeleteChart on page 125 Deletes a chart of the specified type and chart ID CB EnumAssum on page 126 Enumerates assumption cells for all open workbooks CB EnumChart on page 127 Returns the unique name of the next chart of the specified type CB EnumCorrelation on page 128 Enumerates correlated assumptions and correlation values for all open workbooks CB EnumDecVar on page 130 Enumerates decision variable cells for all open workbooks CB EnumFore on page 131 Enumerates forecast cells for all open workbooks 34 Crystal Ball Developer Kit Overview Name CB ExtractData on page 133 Description Extracts data from the current simulation and restored results optimization with an appropriate license or time series forecast using a dialog CB ExtractDataND on page 133 Extracts data from the current simulation and restored results optimization with an appropriate license or time series forecast without a dialog CB Fit on page 139 Fits a specific probability distribution to a range of data and returns information about
128. a dialog CB DefineAssumND Defines an assumption in the selected cell without using a dialog CB GetFitFilter Returns the current value of the specified distribution fitting filter setting CB GetFitParm Returns the value of the specified distribution parameter for the last CB Fit call CB GetLockFitParm Returns whether a distribution and optionally specific parameters have locked values for fitting purposes CB LockFitParm Sets parameter locking for distributions and optionally specific parameters CB SetFitFilter Specifies a data range to include in or exclude from the data range to use as input for CB Fit CB SetFitRange Specifies the data range to use as input for CB Fit CB FormatPrefs This subroutine opens the Axis tab of the Chart Preferences dialog so you can change the axis label preferences axis scale and number formatting for the selected forecast Note Before calling this subroutine to change the axis label preferences for a particular forecast chart select the corresponding forecast cell CB FormatPrefs Example This example runs a simulation of 500 trials selects a forecast cell B7 and then opens the Format Preferences dialog for the forecast in B7 CB Simulation 500 Range B7 Select CB FormatPrefs CB FormatPrefs Related Calls Name Description CB ChartPrefs Sets chart preferences for the selected forecast or assumption using a dialog CB ChartPref
129. aType cbDatStatistics True CB ExtractDataND cbExtDataType cbDatValues True CB ExtractDataND cbExtOK CB ExtractDataND Related Calls Name Description CB CreateRpt Creates a Crystal Ball report from the creates a report from the current simulation and restored results optimization or time series forecast using a dialog CB CreateRptND Creates a Crystal Ball report from the creates a report from the current simulation and restored results optimization or time series forecast without a dialog CB ExtractData Extracts data from the current simulation and restored results optimization or time series forecast using a dialog CB Fit This function fits a specific probability distribution to a set of data range of cells and returns information about the fit CB Fit 139 Table 77 CB Fit Returned Data Type Returned Value The goodness of fit statistic for the fit of the data to the selected distribution Returned Data Type Variant You select the distribution to fit to your data among the possible distributions listed in Table 78 on page 140 and the statistic to return CB Fit must be used with CB SetFitRange CB SetFitRange on page 231 as shown in the examples for this call It can be used with CB SetFitFilter CB SetFitFilter on page 231 to include or exclude specified values from the fit range Table 78 CB Fit Parameters VBA Data Parameter Type Value Description
130. able 22 DoNotApply Boolean True applies changes only to new Crystal Ball cells False applies changes to existing and new Crystal Optional Ball cells The default is False Level Optional Integer Specifies whether changes are applied globally to all open and new workbooks to cells of that type in the active workbook or to cells of that type in the active worksheet depending on the selected constant or index value e cbCelGlobal 0 e cbCelWorkbook 1 e cbCelWorksheet 2 The Index2 parameter listed in the following table Table 21 works with the Value parameter to set cell preferences For Value parameter values see Table 22 Table 21 CB CellPrefsND Index2 Parameter Values Integer Required Constant Value Index Value Description cbCelPattern 1 Sets a pattern choice defined by value Table 22 cbCelColor 2 Sets a color choice defined by Value CB CellPrefsND 69 Constant Value Index Value Description cbCelNote 3 Turns notes on and off depending on value cbCelDistMean 4 Sets the value in assumption cells to be the mean of the defined distribution cbCelRangeMidpoint 4 Sets the value in decision variable cells to be the midpoint of the defined range cbCelDistMedian 5 Sets the value in assumption cells to be the median of the defined distribution cbCelRangeMin 6 Sets the value in decision variable cells to be the minimum of the defined range cbCelRangeMax 7 Sets the value i
131. actually freeze the list To unfreeze cells and freeze different ones use cbFrzClearlist to clear the list of frozen cells and then use cbFrzSetList to either freeze different cells or no cells empty list See CB FreezeND Example on page 148 CB Freeze 147 Note Itis not possible to select a range of cells in the format Range D6 E527 and add that to the list of frozen cells You must select and add each cell individually as shown in CB FreezeND Example on page 148 To freeze a large number of cells the most efficient way is to enumerate through all of the assumptions decision variables and forecasts on the sheet you wish to remove from the simulation and then freeze the Crystal Ball data in those cells one at a time You should be able to refer to the example code for CB EnumAssum for example to see how the enumeration should work When you are done with the simulation you will need to unfreeze the Crystal Ball data in the same way Table 84 CB FreezeND Parameters VBA Data Parameter Type Value Description Index Integer See Table 85 for Defines which assumptions decision variables or forecasts should be frozen Index values hold to their worksheet values during a simulation Values listed in Table 85 are 1 cbFrzAddCell 2 cbFrzClearlist 3 cbFrzSetList Frozen Integer True or False Sets whether the cells in the list created by the Index parameter are frozen during Optional simulations True or enabl
132. aded Indicates whether Crystal Ball is currently loaded within Microsoft Excel CB SetCBAutoLoad Sets or cancels autoloading with Microsoft Excel determines whether Crystal Ball is set to open whenever Microsoft Excel opens CB Shutdown Closes Crystal Ball while leaving Microsoft Excel open CB Startup Loads Crystal Ball into Microsoft Excel if possible and indicates when Crystal Ball has been successfully opened CB GetCertainty This function calculates the certainty level or probability as a percent of achieving a forecast value at or smaller than a specific threshold The value returned is equivalent to setting the right highest value endpoint grabber on the forecast chart to a specific value and obtaining the calculated certainty level You can call this function from either a macro or a worksheet For example suppose trial values for a forecast range from 5 to 300 If you enter 200 for the Value parameter see Table 108 on page 162 CB GetCertainty would return the probability of obtaining a value within the range of 5 to 200 including those end points Note To call this function from a worksheet use the name CB GetCertaintyFN Table 107 CB GetCertainty Returned Data Type Returned Value Returned Data Type Certainty probability as a percent of achieving a value within a range from the minimum up to and including the Variant specified forecast value CB GetCertainty 161 You must run a simulation
133. age 145 works with the Value parameter to set Axis preferences for forecast charts Table 82 CB FormatPrefsND Index parameter values Required Integer Index Named Constant Value Value Description cbFmtFormatType 1 Sets the number format of the axis labels according to the va1ue parameter setting cbFmtUnderlying 2 Sets whether to use the underlying cell format for the axis labels according to the va1ue parameter setting You cannot use any other format preferences unless this option is turned off cbFmtCommas 3 Sets whether to use commas or another thousands separator character indicated in the Windows regional settings in the axis labels according to the va1ue parameter setting This preference is ignored for scientific notation cbFmtDecimalPlace 4 Sets the number of decimal places to use in the axis labels for fixed and scientific number formats according to the Value parameter setting The value parameter Table 83 works with the Index parameter to set forecast chart Axis preferences CB FormatPrefsND 145 Table 83 CB FormatPrefsND Value Parameter Values Required Variant Used With Specified Values of Named Constant or Index Index Boolean Value Value Description For Index 1 cbFmtFormatType cbFttFixed 1 Sets the axis labels to have a fixed decimal place format Integer For Index 1 cbFmtFormatType cbFttGeneral 2 Sets the axis labels to be a general Microsoft Excel Inte
134. ai d ode de oup OR eR oe E o o eoe e E bee CB DeiineFore REE A wersene est 123 CB DefinePoneNDI eocirsaispra eT eee rra nadar 123 CB DefineForeND Example meas as T 124 CE Dieter ore Related lle cara ssa 125 CB DeleteChart srirocrrorirss TT rr 125 CB DeleteChart Example presents s 125 COINCIDA rra dE ORE dee eoe dee O Ce ae U orerar topitur isc sra pride E apes 126 CB Enun scma ExAIHPIe 2 uacesquqescesqepESCRqeqpaeebeqeqasdaqq edu 126 MH Pitas tia E EI ETT 126 Contents vii viii Contents CB EnumChart mes m TER mm PE NUR Ru TRE s 127 ED Envia hart MAA 128 CP EnumChart Riddle 128 CB EnumCorrelation eb d e POS ER bebe redu eee beside 128 CB Enumterelation Example l 4 2 9 2 44 Rr Ra ERE ERE Pe 129 CB Grim oration ampli avidin chee vende aaa 130 CBEpumCorrelation Related Calls 2423 axe AA EA 130 CB EnumDecVar Bs pode oe ae ee Bods nm os 130 CAE Var Ee ks ace Se awi eerie dos eens eee AA ARA PA E Edd 131 CI Pear Related DIU riada ri 131 CR EOUMPOE si n redd us A o ee eee ss BM CD Exumbore Exemple iE ERU EXERCERE ER ER tA EC RS 132 CB EnumFore Related Calls NE A Capea dd tau E 132 LIB ESTACA RA eRe EA Veen A e ARS Gi XA AA ew Ree 133 A MAA 133 CD EsIDuas Related alles errar ri ia dad 133 LB Exhact Lais rara aterra ria ii 133 CB ExtractDataND Example 1 eus ee T de
135. aint equation Is var excluded Inherited from Optvar Get the statistics for this Optimization Variable Statistics are based upon the current OptRuntime solution filter Inherited from OptVar Developing Optimization Code 283 CB Com Devkit chm is generated from actual OptQuest Developer Kit code and has a development language filter to help you with your code The default is C You can change to Visual Basic or Visual Basic Usage for code snippet examples The topic in Figure 3 has two collapsible headings Properties and See Also Other topics such as Decision Class shown in Figure 4 have an additional Syntax heading The Syntax tabs are linked to the Language Filter menu in the help window In Figure 4 the language filter is set to Visual Basic Usage Since the Visual Basic Usage filter shows sample Visual Basic code a code snippet appears on the tab Figure 4 CB Com Devkit chm opened to the Decision Class topic E CB Com Devkit m E e 003 tem Hide Locate Back Stop Refresh Home Print Options Contents index Search ElCollapse All Language Filter Visual Basic Usage Members See Also CB Com Devkit Decisioneering CB CBCOMDevKit Optimization Namespace BooleanOption Enumeration e ConEnumerator Class QQ Constraint Class Decision variable wrapper Constraint Properties Namespace Decisioneering CB CBCOMDevKit Optimization E Constraint Type Property Assembly CBCOMDev
136. al Ball into Microsoft Excel if possible and indicates when Crystal Ball has been successfully opened CB CellPrefs Subtopics e CB CellPrefs Example e CB CellPrefs Related Calls This subroutine opens the Cell Preferences dialog so that you can set cell preferences for existing Crystal Ball data cells or new cells CB CellPrefs Example This example opens the Cell Preferences dialog so you can set and apply new cell preferences CB CellPrefs CB CellPrefs Related Calls Name Description CB CellPrefsND Sets attributes of Crystal Ball cells 68 Crystal Ball Macro Calls CB CellPrefsND Subtopics e CB CellPrefSND Example e CB CellPrefsND Related Calls This subroutine sets attributes of Crystal Ball cells without the Cell Preferences dialog The default for any preference is the previous setting in the Cell Preferences dialog Caution CB CellPrefsND cannot run if a cell with Crystal Ball data is located in a write protected worksheet Table 20 CB CellPrefsND Parameters VBA Data Parameter Type Description Indexl Integer Changes assumption forecast or decision variable cells depending on the selected constant or index value e cbCelAssum 1 e cbCelFore 2 e cbCelDecVar 3 Index2 Integer Sets preferences depending on the Value parameter that follows it For constant and index values see Table 21 Value Variant Works with Index2 to specify preference settings as described in T
137. al list of all Crystal Ball Developer Kit calls with summaries plus tables of related calls e Chapter 3 Crystal Ball Macro Calls 22 Welcome Includes descriptions of all Crystal Ball Developer Kit calls in alphabetical order with examples Chapter 4 Changes from Previous Versions Information about changes since previous releases of Crystal Ball Chapter 5 Crystal Ball Runtime Information about creating applications for people who are not users of Crystal Ball Appendix A Using the OptQuest Developer Kit Describes how to use the Crystal Ball Decision Optimizer OptQuest Developer Kit to automate OptQuest optimizations Appendix B Using the Predictor Developer Kit Describes how to use the Predictor Developer Kit included with all versions of Crystal Ball to automate Predictor time series forecasts Documentation Changes For greater consistency in terminology between the Crystal Ball Developer Kit and VBA The term macro describes a sequence of VBA code created using the Crystal Ball Developer Kit The term function describes a Developer Kit element that returns a value For example the CB GetCertainty function returns the probability of reaching the specified certainty value The term subroutine describes a Developer Kit element that does not return a value for example CB AboutBox The term call or macro call is used generically to describe any Developer Kit function or
138. al parameters you need to leave a space for it set off by a comma LSL Optional Variant A numeric value double a Enters a lower specification limit for the forecast string representing a cell reference such as B1 or coParmUndefined USL Optional Variant A numeric value double a Enters an upper specification limit for the forecast string representing a cell reference such as B1 or coParmUndefined Target Optional Variant A numeric value double a Enters a target value for the forecast string representing a cell reference such as B1 or coParmUndefined CB DefineForeND Example This example defines a new forecast in cell C9 with the name of Profit and no unit label The forecast chart window is set to appear automatically when the simulation starts Range C9 Select CB DefineForeND Profit Wi 1 True True 124 Crystal Ball Macro Calls T CB DefineForeND Related Calls Name Description CB DefineFore Defines forecasts in selected cells using a dialog CB GetFore Retrieves information for a specific forecast cell CB SetFore Changes forecast attributes without redefining the forecast CB DeleteChart This call deletes a chart of the specified type and chart ID The chart ID is optional If the chart ID is not specified the currently selected chart is deleted If the specified chart is not found a chooser dialog appears No error is returned
139. als CB TwoDSimulationND Example 1 This example resets the Crystal Ball simulation selects a target forecast in cell Al resets assumptions to the uncertainty list adds cells to the variability list specifies the number of trials for the uncertainty and variability simulations specifies that only the target forecast chart should display sets output options sets the maximum number of uncertainty simulations to display in the output report and overlay chart to 75 and then runs the tool CB ResetND Select target forecast A1 Select lt Al must contain a forecast CB TwoDSimulationND cbTwoDChooseTarget Set all assumptions to the uncertainty list CB TwoDSimulationND cbTwoDChooseAssum cbTwoDAssumClearList Set cells D3 and F9 to the Variability list D3 Select CB TwoDSimulationND 249 CB TwoDSimulationND cbTwoDChooseAssum cbTwoDAddAssumVar F9 Select CB TwoDSimulationND cbTwoDChooseAssum cbTwoDAddAssumVar Set the outer uncertainty simulation loop to 500 trials CB TwoDSimulationND cbTwoDOuterSimTrials 500 Set the inner variability simulation loop to 250 trials CB TwoDSimulationND cbTwoDInnerSimTrials 250 Set the forecast display to show only charts for the target forecast CB TwoDSimulationND cbTwoDForeOption cbTwoDShowTargetFore Set the report options to include forecast statistics and custom percentiles CB TwoDSimulationND cbTwoDOutputOption cbTwoDshowForeStat
140. alue1 Parameter Optional Variant Named Constant VBA Data Index Related Value Value Type Value Description For Index 3 cbSceMinValue Double 1 If percentiles are used returns the minimum cbSceSelectPercentiles value of the percentile range to work on For Index 3 cbSceMaxValue Double 2 If percentiles are used returns the maximum cbSceSelectPercentiles value of the percentile range to work on For Index 4 cbSceMinValue Double 1 If forecast values are used returns the minimum cbSceSelectForeValues value of the value range to work on For Index 4 cbSceMaxValue Double 2 If forecast values are used returns the maximum cbSceSelectForeValues value of the value range to work on CB GetScenarioAnalysisOption 183 CB GetScenarioAnalysisOption Example These lines of example code return the options set in CB ScenarioAnalysisND Example on page 218 In actual function code the return values should be assigned to variables so they can be displayed or written to a worksheet The following code returns the target forecast cell B1 CB GetScenarioAnalysisOption cbSceChooseTarget Returns cbSceSelectPercentiles Percentiles are used for analysis CB GetScenarioAnalysisOption cbSceRangeForecastResults Returns the minimum value of the percentile range 50th percentile CB GetScenarioAnalysisOption cbSceSelectPercentiles cbSceMinValue Returns the maximum value of the percentile range 75th percentile CB
141. an array called Percents In a macro you can enter CB Simulation 1000 Dim Percents 19 As Double For i 1 To 19 Percents i CB GetForePercent Range C9 i 5 Next i 176 Crystal Ball Macro Calls CB GetForePercent Example 2 This example before a simulation displays 0 in the cell After a simulation it displays the forecast value at the 15th percentile of the forecast in B7 In a worksheet cell you can enter CB GetForePercentFN B7 15 CB GetForePercent Related Calls Name CB GetCertainty Description Returns the certainty level of achieving a forecast value at or smaller than a specific threshold CB EnumFore Enumerates forecast cells for all open workbooks CB GetAssumPercent Returns percentiles for assumption cells CB GetFore Retrieves information for a specific forecast cell CB GetForeStat Returns statistics for forecast cells CB GetForeStat This function calculates the specified statistic for the forecast in the specified cell You can call this function from either a macro or a worksheet Run a simulation before calling this function or else it returns 0 Note To call this function from a worksheet use the name CB GetForeStatEN CB GetForeStatFN only pulls N 1 trials during a recalculation for either a single step or a full simulation but will reflect full trials at the end of the single step or full simulation since a final recalculation is always performed
142. as forecast Targets for process capability analysis The range is a string in the format workbook sheet A 1 cbDataAnalysisAutoOpenCharts Integer 9 Returns a boolean value to indicate whether to open forecast charts automatically when the data analysis runs True cbDataAnalysisSetViewType Integer 10 If charts are shown returns cbChtChartType constants from CB ChartPrefsND to indicate which chart view appears See Table 25 for returned constants cbDataAnalysisFitToDistribution Integer 11 Returns a boolean value to indicate whether forecast charts should be fitted to a distribution True cbDataAnalysisRankingMethod Integer 12 Returns the ranking method for distribution fitting See Table 80 for constants cbDataAnalysisGenerateCorrelationMatrix Integer 13 Returns a boolean value to indicate whether rank correlations between forecast charts should be displayed in a matrix True cbDataAnalysisRunOnAllModels Integer 14 Returns a boolean value to indicate whether a simulation is run on all open workbooks at the same time the selected data is analyzed True cbDataAnalysisNumberOfSeries Integer 15 Returns an integer value equal to the number of currently selected data series CB GetDataAnalysisOption 165 VBA Data Index Named Constant Value Type Value Description cbDataAnalysisNumberOfPoints Integer 16 Returns an integer value equal to the number of points in each data series CB GetDataAnalysisOption Exam
143. ation 168 VB 27 VBA 26 versions Crystal Ball 187 versions data 188 Visual Basic VB script 27 Visual Basic for Applications VBA scripts 26 W welcome to the Developer Kit 21 what you will need 22 278 who this program is for 22 277 294 windows 41 opening CB forecast 197 write protection 32 Index 305 A B C D E F G H L M N OP R S TU V W 306 Index
144. ation before calling this subroutine otherwise CB MacroResult returns cbErrNotReady To apply the subroutine to only one cell select that cell SR 235 Table 199 CB SetRange Parameters VBA Data Parameter Type Value Description Min Optional Variant Any number or Specifies the value of the low end of the certainty range and locks the certainty cbMinuslnfinity grabber there if greater than Infinity If only Min is set Max is set to Infinity and the grabber is unlocked If both Min and Max are set both grabbers are locked Max Optional Variant Any number or Specifies the value of the high end of the certainty range and locks the certainty cbPlusinfinity grabber there if less than Infinity If only Max is set Min is set to Infinity and unlocked If both Min and Max are set both grabbers are locked Certainty Variant Any number between Specifies the certainty level as a percentage to display If Certainty and Optional 0 and 100 Min are both set Max is set to the appropriate value but is not locked If Certainty and Max are both set Minis setto the appropriate value but is not locked A11 Optional Variant True or False Specifies whether to apply this subroutine to all forecasts True or just the selected forecast cell False The default is False If this parameter is set to False and the selected cell contains no forecast CB MacroResult returns cbErrNoForecastInCell You can specify one or
145. ation may provide access to or information on content products and services from third parties Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third party content products and services Oracle Corporation and its affiliates will not be responsible for any loss costs or damages incurred due to your access to or use of third party content products or services Documentation Accessibility coc ais AAA AAA ee er ee gas 19 Chapter 1 Welcome PE E a a od ed ind NN iod Dou deus gari dud m About the Oracle Ceti Ball eves M A 21 Who Should Use the Crystal Ball Developer Kit dd er zx 22 WILTON WU NEJ crue 22 How This Manual ig Organet ok eh eee keke thre pees RW GRE xA PANET ean ARA 22 Documentation Changes A 23 Technical Support and More TET E TET er ee TEP se ae Chapter 2 Crystal Ball Developer Kit Overview taria ras 25 Gi A EE ERE EPA ERO CAR EA ERR nes How to Use the Crystal Ball Developer Kit 1a cead ke hh ER EROR CAO T 20 Calling Crystal Ball From Visual Basic For Applications VBA Programs 26 Calling Crystal Ball From an External Visual Basic VB Program 27 Craie a Ea Peel Adda reia A 28 Using Developer Kit Macro Calls in User defined Macros 000000 ee 28 A Note About Defaults and Write Protection PS dud
146. ation rows For Index 3 cbDataAnalysisDatalnColumns Integer 2 Indicates that data cells are in cbDataAnalysisDataOrientation columns For Index 4 True or False Boolean n a Indicates whether to include cbDataAnalysisSelectHeaders column header text in the selection True include the top row of text For Index 5 True or False Boolean n a Indicates whether to include row cbDataAnalysisSelectLabels label text in the selection True include the first column of text For Index 6 A cell reference with Variant n a Sets the selected range of values cbDataAnalysisSelectLSL format Range A1 C300 or as forecast LSLs lower A1 C300 specification limit for process capability analysis For Index 7 A cell reference with Variant n a Sets the selected range of values cbDataAnalysisSelectUSL format Range A1 C300 or as forecast USLs upper A1 C300 specification limit for process capability analysis For Index 8 A cell reference with Variant n a Sets the selected range of values cbDataAnalysisSelectTarget formatRange A1 C300 or as forecast Targets target A1 C300 values for process capability analysis For Index 9 True or False Boolean n a Indicates whether to open cbDataAnalysisAutoOpenCharts forecast charts automatically when the data analysis runs True automatically open charts For Index 10 Constants Table 25 Integer See Uses cbChtChartType constants cbDataAnalysisSetViewType Table 25 from CB ChartPrefsND to de
147. ay charts to include in the cbChartAdd the selected report when used with chart is added CB SelectChart cbRptChooseTrend 29 Clears adds and sets the Integer See Table 40 If n a trend charts to include in the cbChartAdd the selected report when used with chart is added CB SelectChart cbRptChooseSensitivity 30 Clears adds and sets the Integer See Table 40 If n a sensitivity charts to include in cbChartAdd the selected the report when used with chart is added CB SelectChart cbRptChooseScatter 31 Clears adds and sets the Integer See Table 40 If n a scatter charts to include in the report when used with CB SelectChart cbChartAdd the selected chart is added 94 Crystal Ball Macro Calls Index Named Constant Value Value Description Value1 Optional Value2 Optional cbRptDefinedType 32 Selects a predefined report Integer See Table 41 n a type or uses the settings defined by the various CB CreateRptND constants cbRptSheetName 33 Specifies the sheet name String The sheet name to n a create cbRptincludeCellLocs 34 Includes the cell location inthe Boolean True includes the n a report cell location information False does not cbRptSection 35 Indicates whether to include or Boolean True includes the Integer See Table 42 exclude entire report sections report section specified in Value2 False excludes the specified section cbRptSectionOrde
148. bChtChartType cbTypArea 1 Changes the assumption or forecast chart type to an area Integer chart For Index 1 cbChtChartType cbTypOutline 2 Changes the assumption or forecast chart type to an Integer outline chart For Index 1 cbChtChartType cbTypColumn 3 Changes the assumption or forecast chart type to a column Integer chart For Index 2 cbChtDistType cbDstFrequency 1 Changes the distribution type to a frequency distribution Integer For Index 2 cbChtDistType cbDstCumulative 2 Changes the distribution type to a cumulative frequency Integer distribution For Index 2 cbChtDistType cbDstReverseCumul 3 Changes the distribution type to a reverse cumulative Integer frequency distribution For Index 3 cbChtGroups cbGrp15 1 Equivalent to the Chart Bins Density setting of Lowest on Boolean the General tab of the Chart Preferences dialog For Index 3 cbChtGroups cbGrp25 2 Equivalent to the Chart Bins Density setting of Low on the Boolean General tab of the Chart Preferences dialog For Index 3 cbChtGroups cbGrp50 3 Equivalent to the Chart Bins Density setting of Low on the Boolean General tab of the Chart Preferences dialog For Index 3 cbChtGroups cbGrp75 4 Equivalent to the Chart Bins Density setting of Medium on Boolean the General tab of the Chart Preferences dialog For Index 3 cbChtGroups cbGrp100 5 Equivalent to the Chart Bins Density setting of High on the Boolean General tab of the Chart Preferences dialog For In
149. because a CB Enum call follows selects the next scatter chart in the workbook and then copies it CB Simulation 1000 CB CheckData CB SelectChart cbChtScatter CB EnumChart cbChtScatter CB CopyScatter 84 Crystal Ball Macro Calls CB CopyScatter Related Calls Name Description CB CloseChart Closes the selected chart of the given type CB EnumChart Returns the unique name of the next chart of the specified type CB OpenChart Opens the selected chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB CopySensitiv Subtopics e CB CopySensitiv Example e CB CopySensitiv Related Calls This call copies the selected sensitivity chart to the clipboard If more than one chart is found but one is not selected a chooser dialog appears CB CopySensitiv Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next sensitivity chart in the workbook and then copies it CB Simulation 1000 CB CheckData CB SelectChart cbChtSensitiv CB EnumChart cbChtSensitiv CB CopySensitiv CB CopySensitiv Related Calls Name Description CB CloseSensitiv Closes the selected sensitivity chart CB EnumChart Returns the unique name of the next chart of the specified type CB OpenSensitiv Opens the selected sensitivity chart CB SelectChart Selects the chart with the specified chart ID CB CopySensitiv 85
150. before you call this function or it returns 0 Table 108 CB GetCertainty Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 Points to the forecast cell for which you want the certainty value In a worksheet B3 Value Double Any number Specifies the desired value CB GetCertainty Example 1 This example runs a simulation of 1000 trials and then pastes the certainty of the forecast in B7 being less than or equal to 15 000 into cell M6 In a macro you can enter CB Simulation 1000 Range M6 Value CB GetCertainty Range B7 15000 CB GetCertainty Example 2 This example before a simulation displays VALUE in the cell After a simulation it displays the certainty of the forecast in B7 being less than or equal to 15 000 In a worksheet cell you can enter CB GetCertaintyFN B7 15000 CB GetCertainty Related Calls Name Description CB EnumFore Enumerates forecast cells for all open workbooks CB GetAssumPercent Returns percentiles for assumption cells CB GetForePercent Returns percentiles for a specific forecast CB GetForeStat Returns statistics for forecast cells CB Simulation Runs a Crystal Ball simulation CB GetCorrelation This function returns the correlation coefficient defined between two assumption cells For a call with fewer parameters that works across worksheets see CB GetCorrelationByRef on
151. bsolete Example escoria rr AA 52 CB AlertOnObsolete Related Calls Tm Rd T eee Be CE Cee A AAA A lt 53 CB AssumPrefsND Example aaa Te ee ee aaa 53 CB AutoDownshift 22 ves saw des EA LE E ALS weed Rowe es 53 CB AutoDownshift Example 1 ees aas 54 CD uso Emp S iria iia ia BE CB BatchPit dasa suqetesebe qe a Husa sque LEST dq EISE qaddia d 54 CB BatchFit Example bes seas bes m Kx s ada re eee oo CE ete AAA bos odo aioe 1684486 ARA thd tbe vee Rw T si iussa bx Kd URP UERRA RA DOE REDE MER Ad KC RERO do ee CB BatchPIND Example l ricas rai AAA 61 ad A apa T EE ue pd do obe ge ue t qmod 62 Pie RACHA dE QE E E PS 62 CODO scared agrario 63 CB Bootstrap Example ewe or er 63 CB Boolsrap PAPA CB BootstrapND caricias AAA AA AER 63 CB BootstrapND Example 1 or 00 CE bootstiapN ll EXSMDIE A ais rr a 66 A a e MAA 66 BASS PDA arriva di AAA 67 CB CalculateSpearman Related Calls CERA 1 eze OF A ae er eee E ene Se eee eee ee ame ye er ree emer ere 07 CB CBLoaded Exaxaple gis ci eased k dd Rh REG d ARR Gear OTE AA 68 CB CBLoaded Related Calls ates ee T ed pes ee 68 te AAA 68 A AMA 68 CB CellPrefs Related Calls A A PA 68 CBCP PEND visere ina Am piss T ind es UY CB CellPrefsND Example EAN ee aut E barca 70 CILCElPre ND Related Call ricos Arabe 71
152. cVarType 20 Includes the type for each Boolean True includes the n a included decision variable type False does not cbRptAssumStatistics 21 Includes the statistics table for Boolean True includes the n a each included assumption statistics False does not cbRptAssumPercentiles 22 Includes the percentile data for Boolean True includes Integer Same as that each included assumption percentile data False does for cbRptFore not Percentiles See Table 34 following cbRptAssumCorr 23 Includes the correlations for Boolean True includes the n a each included assumption correlations False does not cbRptOverlayCharts 24 Includes the distribution graph Boolean True includes the Integer 1 to 200 for each included overlay chart charts False does not defines the percent scale of the charts cbRptTrendCharts 25 Includes the graph for each Boolean True includes the Integer 1 to 200 included trend chart charts False does not defines the percent scale of the charts cbRptSensitivityCharts 26 Includes the graph for each Boolean True includes the Integer 1 to 200 included sensitivity chart charts False does not defines the percent scale of the charts cbRptScatterCharts 27 Includes the graph for each Boolean True includes the Integer 1 to 200 included scatter chart charts False does not defines the percent scale of the charts cbRptChooseOverlay 28 Clears adds and sets the Integer See Table 40 If n a overl
153. cbAssumShowCoordinates is removed obsolete in Crystal Ball 7 x and later including 11 x CB AutoDownshift e Starting with Crystal Ball version 7 2 this call changes from a subroutine to a function and returns the boolean setting of the TurnOn parameter True if CB AutoDownshift is set to automatically downshift to Normal speed or False if it is not set to downshift CB BatchFitND e Starting with Crystal Ball version 11 1 2 1 000 two new constants are added to Index o cbBftOutputOrientation 30 with Valuel constants cbBftOutputRows 1 and cbBftOutputColumns 2 o cbBftOutputSheetName 31 which sets the name of the worksheet containing primary fit results assumptions as the string given for Valuel e Starting with Crystal Ball version 11 1 2 3 500 two constants are removed from Index and will now trigger an Obsolete error o cbBftOutputCorrelation 15 o cbBftOutputCorrelationThreshold 26 CB CellPrefsND e Index2 parameter new constants added o cbCelDistMedian 5 o cbCelRangeMin 6 e Value parameter constant cbCelPattern 1 has 0 17 values instead of 0 3 additional values are added for the new Index2 constants with indices 5 7 e Level parameter optional added to support the new Apply To dialog control with new constants o cbCelGlobal 0 o cbCelWorkbook 1 o cbCelWorksheet 2 258 Changes from Previous Versions CB ChartPrefsND e Index parameter constant removed obsolete
154. cbBtsSample 6 Used with Index2 to set sample options cbBtsForeOption 7 Used with Index2 to set forecast chart window display options cbBtsRun 8 Runs the Bootstrap tool Table 16 CB BootstrapND Index2 Parameter Optional Integer Index Related Value Named Constant Value Value Description For Index 3 cbBtsMethod Integer cbBtsMethodResample 1 Runs one simulation and resamples the data faster but less accurate For Index 3 cbBtsMethod Integer cbBtsMethodMultiSim 2 Runs multiple simulations and creates diverse data slower but more accurate For Index 4 cbBtsAnalyze cbBtsAnalyzeStat 1 Analyzes distributions of statistics Integer For Index 4 cbBtsAnalyze cbBtsAnalyzePercent 2 Analyzes distributions of percentiles Integer For Index 4 cbBtsAnalyze cbBtsAnalyzeCapMetrics 3 Analyzes distributions of process capability metrics Integer only available if process capability metrics are activated on the Statistics tab of the Crystal Ball Run Preferences dialog or using the CB RunPrefsND call 64 Crystal Ball Macro Calls Index Related Value Named Constant Value Value Description For Index b cbBtsPercent cbBtsPercentTenNinety 1 Specifies the 10th and 90th percentiles Integer For Index 5 cbBtsPercent cbBtsPercentFiveNinetyFive 2 Specifies the 5th and 95th percentiles Integer For Index b cbBtsPercent cbBtsPercentQuartiles 3 Specifies quartiles
155. cbChtRedrawFrequency 4 CB CheckData e Should now be called each time data is deleted or added as well as each time a new enumeration is started CB ClearData e Ifthe selected range contains more than one type of data a dialog appears and prompts for the type of data to clear e Simulations must now be reset before CB ClearData is called CB ClearDataND e Simulations must now be reset before CB ClearDataND is called CB CloseFore e Can now be called while a simulation is running CB CloseSensitiv e Achart can now be explicitly selected via CB EnumChart and CB SelectChart before it can be closed CB CloseTrend e Achart can now be explicitly selected via CB EnumChart and CB SelectChart before it can be closed CB CopyData and CB CopyDataND e Data is no longer copied to Crystal Ball s internal clipboard Instead these calls record a range of data to be pasted All Crystal Ball data within that range is pasted when CB PasteData runs For this reason CB PasteData should be called immediately after CB CopyData or CB CopyDataND before any data is changed within the copied range e ForCB CopyDataND the documentation is corrected to match the code parameter CBData is renamed DataType Changes to Existing Calls 259 CB CorrelateND e Anew optional parameter SecondAssum is added to specify a second cell to correlate with the cell specified by the first parameter The cell specified by SecondAssum can be on a
156. cbScatterLineColor 5 The next commands draw the correlation coefficient in each plot but do not show the regression properties CB ScatterPrefsND cbScatterDrawCorrelationCoefficient True CB ScatterPrefsND cbScatterShowLinearRegressionCoefficients False The next command opens the chart CB OpenChart cbChtScatter CB ScatterPrefsND Related Call Name Description CB ScatterPrefs Opens the Scatter Preferences dialog for the selected scatter chart CB ScenarioAnalysis The Scenario Analysis tool runs a simulation and then sorts and matches all the resulting values ofa target forecast with their corresponding assumption values Then you can investigate which combination of assumption values gives a particular result You can run Scenario Analysis on any Crystal Ball model with at least one assumption and forecast that are not frozen You select a target forecast to analyze and then the forecast s percentile or value range to examine The resulting table shows all the values for the target forecast in the designated range sorted along with the corresponding assumption values CB ScenarioAnalysis opens the Scenario Analysis wizard so you can run the tool CB ScenarioAnalysis Example This example resets the Crystal Ball simulation and opens the Scenario Analysis wizard CB ScenarioAnalysis 215 CB ResetND CB ScenarioAnalysis CB ScenarioAnalysis Related Calls Name Description CB GetScenarioAnalysisOption
157. cell using a dialog CB DefineDecVarND Defines or changes a decision variable in a selected cell without a dialog CB GetDecVar Retrieves information for a specific decision variable cell CB SetExcel2007ForegroundMode This function is used in Microsoft Excel 2007 or later to set the Normal Speed preference Bring Microsoft Excel 2007 or later to the foreground while running Normal speed simulations faster When set to True this call runs simulations at optimal speed when using Normal speed in Microsoft Excel 2007 or later This call is equivalent to setting the referenced preference manually in the Normal Speed options dialog accessed by selecting Run Preferences then Speed then Normal Speed and then Options Table 191 CB SetExcel2007ForegroundMode Parameter Parameter VBA Data Type Value Description Enable Boolean True or False Indicates whether to run Microsoft Excel 2007 or later in the foreground when using Normal speed True is equivalent to manually checking the preference in the Normal Speed options dialog False is equivalent to manually unchecking the preference CB SetExcel2007ForegroundMode Example This example unchecks or clears the preference Bring Microsoft Excel 2007 or later to the foreground while running Normal speed simulations faster in the Normal Speed options dialog accessed manually by choosing Normal Speed on the Speed tab of the Run Preferences dialog and then
158. chieving a forecast value at or smaller than a specific threshold CB GetCorrelation on page 162 Returns the correlation between two assumption cells CB GetCorrelationByRef on page 163 Returns the correlation between two assumption cells using two parameters CB GetDataAnalysisOption on page 164 Returns current settings for the Data Analysis tool CB GetDecisionTableOption on page 166 Returns current settings for the Decision Table tool CB GetDecVar on page 168 Retrieves information for a specific decision variable cell CB GetExcel2007ForegroundMode on page 169 Returns the current Run Preferences foreground mode setting for Microsoft Excel 2007 or later in Normal speed CB GetFitFilter on page 170 Returns the current value of the specified distribution fitting filter setting CB GetFitParm on page 171 Returns the value of the specified distribution parameter for the last CB Fit call CB GetFore on page 173 Retrieves information for a specific forecast cell Alphabetic List of Crystal Ball Macro Calls 35 Name CB GetForeData on page 175 Description Returns specified forecast data for a given trial CB GetForePercent on page 176 Returns the value corresponding to a percentile for a specific forecast CB GetForeStat on page 177 Returns statistics for a specific forecast cell CB GetLockFitParm on page 180 Returns
159. classes open CB Com Devkit chm in the Docs folder beneath the main Crystal Ball installation folder by default C Program Files Oracle Crystal Ball You can use this file as a reference at any time For more information on this help system and how to use it see CB Com Devkit chm on page 282 Optimization Setup Classes The following are the main OptQuest Developer Kit classes used for setting up an optimization e OptSetup main class for setting up optimizations e OptSetup Constraint e OptSetup Decision e OptSetup Objective e OptSetup OptEfficientFrontier e OptSetup OptOptions e OptSetup Requirement OptQuest Developer Kit Use and Structure 279 OptSetup This class is the main class for setting up optimizations You can use its methods and properties to access optimization variables that is to add modify and delete variables and options for running optimizations OptSetup Constraint This class represents an OptQuest constraint and accesses constraint properties OptSetup Decision This class serves as a wrapper for Crystal Ball decision variables and accesses their properties OptSetup Objective This class is responsible for handling all operations related to OptQuest objectives OptSetup OptEfficientFrontier This class accesses OptQuest settings for Efficient Frontier analysis OptSetup OptOptions This class accesses OptQuest option settings the preferences that control how long the optimization r
160. clicking the Options button When set to False simulations in Microsoft Excel 2007 or later might run more slowly than if the preference were set to True the default CB SetExcel2007ForegroundMode False CB SetExcel2007ForegroundMode Related Call Name Description CB GetExcel2007ForegroundMode Returns the current Run Preferences foreground mode setting for Microsoft Excel 2007 or later in Normal speed 230 Crystal Ball Macro Calls CB SetFitFilter This function can be used with CB Fit CB Fit on page 139 and CB SetFitRange CB SetFitRange on page 231 to specify a range of data to include in or exclude from the input data selected for distribution fitting You can specify either an inclusive or exclusive filter range The use of this call is optional Table 192 CB SetFitFilter Returned Data Type Returned Value Whether the fit filter setting was successful Returned Data Type Variant This subroutine has four required parameters Table 193 CB SetFitFilter Parameters with Values on page 231 Table 193 CB SetFitFilter Parameters with Values Parameter VBA Data Type Value Description UseFilter Boolean True or False Indicates whether to apply filtering to the input data if True filtering is applied FilterInside Boolean True or False Specifies which input values are discarded when filtering True discards values inside the filtering range False discards values outside the range
161. constants are added for Value2 described in Table 34 cbPctSet3 7 cbPctSet4 8 o cbRptChooseAssum a new constant is added for Valuel cbChaOpen 5 described in Table 36 o cbRptChartType the constant cbChtBW 0 is now obsolete and has been removed 260 Changes from Previous Versions 000000 To support the rewritten version of OptQuest added in version 11 1 1 0 00 O The following new Index constants are added cbRptOptimizerSummary 39 cbRptOptimizerChart 40 cbRptOptimizerBestSolution 41 cbRptOptimizerConstraints 42 cbRptOptimizerDecVars 43 A new report section type is available as Value2 for cbRptSection cbRptSectOptimizerResults 9 A new Value2 constant is available for cbRptDefinedType cbRptOptimizer 7 A ninth integer is available for cbRptSectionOrder the cbRptSectOptimizerResults section is assigned number 9 To support the rewritten version of Predictor added in version 11 1 3 0 00 O The following new Index constants are added cbRptPredictorChart 45 cbRptPredictorStatistics 46 cbRptPredictorAutocorrelations 47 cbRptPredictorForecast 48 cbRptPredictorConfidenceIntervals 49 and cbRptPredictorMethods 50 A new report section type is available as Value2 for cbRptSection cbRptSectPredictorSeries 10 New Valuel constants are available for cbRptPredictorMethods cbPredictorMethodsNone 1 cbPredictorMethodsAIl 2 cbPredictorMethods1 Best 3 cbPredictorMethods
162. create or update excel exe config run the following script after the installation script AddInManager ConfigExcelForDotNet This script should be adjusted to run the Crystal Ball AddInManager from the Bin folder beneath the main Crystal Ball installation folder by default c Program Files Oracle Crystal Ball Bin The resulting file excel exe config appears in C Program Files Microsoft Office Office where Office indicates the default version of Microsoft Office including Microsoft Excel that Crystal Ball opens when it starts If excel exe config already exists the information relevant to Crystal Ball is appended to it or updated as appropriate The new information in excel exe config indicates that Crystal Ball should use Microsoft NET Framework 2 0 3 0 or 3 5 Licensing Script A major part of Crystal Ball Runtime licensing is entering a license serial number so those who receive Crystal Ball Runtime applications are able to run them on their computers The serial number is supplied by the Crystal Ball team for distribution through direct installation and licensing or through scripts and allows a certain number of activations Users of your applications can install and license Crystal Ball directly following instructions in the current Oracle Crystal Ball Installation and Licensing Guide Alternatively you can use a script for licensing also described in the Oracle Crystal Ball Installation and Licensing Guide Note C Users
163. crete and a title of Rent Per Unit Range C9 Select CB DefineDecVarND 400 600 10 Rent Per Unit This definition is the same except the decVarType parameter is used Range C9 Select CB DefineDecVarND 400 600 10 Rent Per Unit cbDecVarTypeDiscrete CB DefineDecVarND Example 2 This example defines a new decision variable in cell D12 with a lower bound of 500 an upper bound of 800 no step size also defining the decision variable as Continuous and a title of Net Income Range D12 Select CB DefineDecVarND 500 800 Net Income This definition is the same except the decVarType parameter is used Range D12 Select CB DefineDecVarND 500 800 Net Income cbDecVarTypeContinuous CB DefineDecVarND 121 CB DefineDecVarND Example 3 This example defines a new decision variable in cell F10 with a lower bound of 0 an upper bound of 1 no step size a title of Net Income and a decision variable type of Binary The values of Min and Max are ignored for Binary decision variables but they must be entered since they are required parameters for CB DefineDecVarND Ifa step size is entered for this decision variable type it is ignored Range F10 Select CB DefineDecVarND 0 1 Net Income cbDecVarTypeBinary CB DefineDecVarND Example 4 Crystal Ball example model Groundwater Cleanup xls contains two decision variables The decision variable in cell D13 is named Remediation Method It has a lower bound
164. cription CB ClearDataND Clears assumptions decision variables and forecasts from selected cells without confirmation CB CopyData Copies Crystal Ball data in the specified range CB CopyDataND Copies selected assumptions decision variables or forecasts CB PasteData Pastes assumptions decision variables or forecasts into selected cells CB ClearData 77 CB ClearDataND Subtopics e CB ClearDataND Example e CB ClearDataND Related Calls This subroutine erases assumptions decision variables and forecasts from selected cells The values and formulas in the cells remain The worksheet must be active and the selected cell or range of cells must contain assumptions decision variables or forecasts If the range contains more than one type of cell all types are cleared Unlike CB ClearData CB ClearDataND does not ask the user for confirmation Note Before calling this subroutine reset the current simulation and select a cell or cell range containing Crystal Ball data CB ClearDataND Example The following lines of code reset the simulation and clear the selected Crystal Ball data without any prompting CB ResetND CB ClearDataND The cell contents such as a value cell reference or formula remain CB ClearDataND Related Calls Name Description CB ClearData Erases assumptions decision variables and forecasts from selected cells after prompting CB CopyData Copies Crystal Ball data in sp
165. crosoft Excel COM Add ins dialog and check or uncheck Crystal Ball For more information on these alternatives see Starting Crystal Ball in the current Crystal Ball Installation and Licensing Guide No matter which alternative you use the same setting appears in either of the other two alternatives including the CB SetCBAutoLoad call The autoload setting is persistent once set it remains set until one of the alternatives is used to change it Table 185 CB SetCBAutoLoad Parameter Parameter VBA Data Type Named Constant Value Description autoLoad Boolean True or False True sets Crystal Ball to autoload each time Microsoft Excel starts False deactivates autoloading CB SetCBAutoLoad Example This code sets Crystal Ball to automatically start when Microsoft Excel starts CB Set CBAutoLoad True CB SetCBAutoLoad Related Calls Name Description CB CBLoaded Indicates whether Crystal Ball is currently loaded within Microsoft Excel CB GetCBAutoLoad Returns the current Crystal Ball autoload setting that indicates whether Crystal Ball is set to open whenever Microsoft Excel opens CB Shutdown Closes Crystal Ball while leaving Microsoft Excel open CB Startup Loads Crystal Ball into Microsoft Excel if possible and indicates when Crystal Ball has been successfully opened CB SetCBWorkbookPriority This subroutine sets the running order for Crystal Ball macros when multiple workbooks are ope
166. d Data Type Returned Value Returned Data Type The absolute cell reference of the next assumption in the format workbook sheet A 1 Variant Note For best results call CB CheckData once at the beginning of an enumeration to reset the sequence of assumptions You should also call CB CheckData each time you add or delete data Use CB CheckData or CB CheckDataND with CB MacroResult and CB MacroResultDetail to check for errors For more information see the descriptions of those calls If the return string is empty all assumptions have been enumerated You can use the results of this subroutine to create a Range object You can only call this function from a subroutine or another function You cannot call this function from a worksheet CB EnumAssum Example This example initializes all internal variables then steps through all the assumptions creating range objects from the returned string and putting their absolute cell references in column B of a worksheet CB CheckData Dim S As String Dim R As Range Dim t As Integer S CB EnumAssum While S lt gt Set R Range S Range B2 Off set t Value s t s t 4 21 S CB EnumAssum Wend CB EnumAssum Related Calls Name Description CB EnumDecVar Enumerates decision variable cells for all open workbooks 126 Crystal Ball Macro Calls Name Description CB EnumFore Enumerates forecast cells for all open workbooks CB GetAssum Retrieves informa
167. d provides lists of macro calls subroutines and functions from different categories with references to Chapter 3 for detailed definitions and examples The chapter begins with instructions for using the Crystal Ball Developer Kit followed by an alphabetical list of the Crystal Ball calls including a brief summary of the actions they perform This section serves as an index to the Crystal Ball calls in Chapter 3 The following sections list groups of macro calls used for various purposes Spreadsheet Functions For Use in Microsoft Excel Models on page 38 Opening and Closing Crystal Ball on page 39 Setting Up and Running Simulations on page 39 Controlling Crystal Ball Chart Windows on page 41 Handling Crystal Ball Results on page 42 Setting and Getting Preferences on page 43 Special Calls on page 44 Introduction 25 How to Use the Crystal Ball Developer Kit Subtopics Calling Crystal Ball From Visual Basic For Applications VBA Programs Calling Crystal Ball From an External Visual Basic VB Program Creating a Microsoft Excel Add in Using Developer Kit Macro Calls in User defined Macros A Note About Defaults and Write Protection Putting Custom Applications into Runtime Mode This section describes how to call the Crystal Ball Developer Kit routines and functions Note that macros created with the Crystal Ball Developer Kit cannot be placed in spreadsheet cells although some
168. dex 3 cbChtGroups cbGrp150 6 Equivalent to the Chart Bins Density setting of High on the Boolean General tab of the Chart Preferences dialog For Index 3 cbChtGroups cbGrp300 7 Equivalent to the Chart Bins Density setting of Highest on Boolean the General tab of the Chart Preferences dialog For Index 5 cbChtMeanLine True or False n a Turns on True or off False the mean line Boolean For Index 6 cbChtHorizGrids True or False n a Turns on True or off False the horizontal grid lines Boolean CB ChartPrefsND 73 Note See the Oracle Crystal Ball User s Guide for more information on how to customize assumption and forecast charts CB ChartPrefsND Example This example selects a forecast cell and then changes its forecast chart to show a mean line Range B7 Select CB ChartPrefsND cbChtMeanLine True CB ChartPrefsND Related Calls Name Description CB ChartPrefs Displays the Chart Preferences dialog CB CheckData Subtopics e CB CheckData Example e CB CheckData Related Calls This subroutine scans Crystal Ball data on open worksheets checking the validity of all Crystal Ball data objects including assumptions decision variables forecasts and correlations Then it initializes internal variables If errors occur appropriate dialogs appear and you are prompted to correct them You should call CB CheckData or CB CheckDataND when modifying the structure of the worksheet or workbo
169. donotcreatea reference to CBDevKit xla Crystal Ball calls will not be accessible from your VBA program Calling Crystal Ball From an External Visual Basic VB Program Using Crystal Ball from Visual Basic 4 0 or higher is somewhat more complicated than using it from Visual Basic for Applications To access Crystal Ball calls you must first get a reference to the Microsoft Excel application object To do this run the following procedure before running Crystal Ball subroutines and functions Private Sub LoadCB On Error Resume Next Set XL CreateObject Excel Application Parent XL Visible True Set CB XL Workbooks CBDevKit xla Modules CB If Not IsObject CB Then Set CB XL Workbooks Open filename _ C Program Files Oracle Crystal Ball CBDevKit xla End If End Sub If you have stored the file CBDevKit xla in some other directory than C Program Files Oracle V then substitute the appropriate path name This procedure gets a reference to the Microsoft Excel application object and puts itinto variable XL Then this variable is used to determine if Crystal Ball is already loaded If the Crystal Ball Developer Kit is not loaded the procedure loads it You cannot use Crystal Ball as an OLE automation object You should call its subroutines and functions through a call to Microsoft Excel s Run macro The first parameter is the name of a Crystal Ball subroutine or function Other parameters are passed to t
170. e Returned Value Returned Data Type The current TurnOn parameter setting Boolean Table 8 CB AutoDownshift Parameters Parameter VBA Data Type Named Constant Value Description TurnOn Variant True or False True turns on automatic downshifting from Extreme speed to Normal speed False turns it off CB AutoDownshift Example 1 This example sets Crystal Ball to automatically downshift to Normal speed when a model cannot run in Extreme speed and returns TRUE in cell B2 Range B2 Value CB AutoDownshift True CB AutoDownshift Example 2 To retrieve the current setting of CB AutoDownshift use this call in a function in the following form ReturnValue CB AutoDownshift CB BatchFit Subtopics e CB BatchFit Example e CB BatchFit Related Calls This call launches the Batch Fit tool wizard This tool helps define assumptions when you have historical data for a number of variables The tool automatically selects which probability distribution binomial normal triangular uniform and so on best fits each series of historical data and returns the parameters to use in your model Batch Fit can also provide a table of goodness of fit statistics and a correlation matrix calculated between the historical data 54 Crystal Ball Macro Calls Note Before calling CB BatchFit reset the simulation CB BatchFit Example This example resets the Crystal Ball simulation and opens the Batch Fit wiza
171. e The next comma nds add assumptions D4 through D6 to the scatter chart Range D4 Select CB ScatterPrefsND cbScatterManageAssum cbScatterAddSelectedVar Range D5 Select CB ScatterPrefsND cbScatterManageAssum cbScatterAddSelectedVar Range D6 Select CB ScatterPrefsND cbScatterManageAssum CB ScatterPrefsND cbScatterTitle CB ScatterPrefsND cbScatterViewType The next comma The next comma cbScatterAddSelectedVar nd sets the scatter chart title Piston Displacement Scatter View nd makes sure the scatter chart is in Scatter view cbScatterView 214 Crystal Ball Macro Calls The next command sets minimal plot size valid range is 1 10 CB ScatterPrefsND cbScatterPlotSize 1 The next command sets Criteria Limit to Auto displays number of plots appropriate to plot size CB ScatterPrefsND cbScatterCriteriaLimit cbScatterLimitAuto The next commands specify properties of the plot points triangle size 4 color light green CB ScatterPrefsND cbScatterDrawPoints True CB ScatterPrefsND cbScatterPointSymbol cbScatterPointSymbolTriangle CB ScatterPrefsND cbScatterPointSize 4 CB ScatterPrefsND cbScatterPointColor 2 The next commands draw a linear regression line on top of points width 2 color purple CB ScatterPrefsND cbScatterDrawLines True CB ScatterPrefsND cbScatterLineType cbScatterRegression CB ScatterPrefsND cbScatterLineWidth 2 CB ScatterPrefsND
172. e for the distribution or the actual value of the Variant locked parameter or coParmUndefined if the parameter is not locked or cannot be locked CB GetLockFitParm has the parameters shown in Table 138 Table 138 CB GetLockFitParm Parameters VBA Data Parameter Type Value Description Dist Integer Distribution name constants as listed in Table 55 Valid Indicates the distribution for locked distributions are gamma lognormal Student s t Weibull parameter information binomial and hypergeometric ParameterIndex Integer See Table 55 Valid distribution and parameter Returns the locked value setting for Optional combinations are the specified distribution parameter G distributi Location Sh t combination If the value has been e Gamma distribution Location Shape parameters cleared or the combination is not e Lognormal distribution Location parameter valid coParmUndefined is returned e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter 180 Crystal Ball Macro Calls CB GetLockFitParm Example The following macro statements define two variables named LockVal and useLock lock the Location parameter of the Weibull distribution and set it to the value of 250 unlock the same parameter for the gamma distribution while setting the value of that parameter
173. e 49 CB DecisionTableND Index2 Parameter Optional Integer Index Related Value Named Constant Value Value Description For Index 2 cbDec cbChdAdd 3 Used with coDecChooseDecVar to add the decision variable ChooseDecVar Integer in the selected cell to the list of chosen decision variables For Index 2 cbDec cbChdClearList 4 Used with coDecChooseDecVar to clear the list of chosen ChooseDecVar Integer decision variables For Index 3 coDecSimOption cbDecNumValuesVar1 1 Used with cbDecSimOption to specify the number of test Integer values to use for the first selected decision variable For Index 3 cbDecSimOption cbDecNumValuesVar2 2 Used with cbDecSimOption to specify the number of test Integer values to use for the second selected decision variable For Index 3 cbDecSimOption cbDecSimTrials 3 Used with coDecSimOption to specify the maximum number Integer of trials for each simulation For Index 4 cbDecForeOption cbDecShowDefinedFore 1 Used following cbDecForeOption the equivalent of the Show Integer Forecasts As Defined dialog setting For Index 4 cbDecForeOption cbDecShowTargetFore 2 Used following cbDecForeOption the equivalent of the Show Integer Only Target Forecast dialog setting For Index 4 cbDecForeOption cbDecHideFore 3 Used following cbDecForeOption the equivalent of the Hide Integer All Forecasts dialog setting CB DecisionTableND 107 Table 50 CB DecisionTableND Value Paramet
174. e Crystal Ball then Examples and then View Examples Guide From the list of examples select Toledo Gas With the example model open open the Microsoft Excel Visual Basic Editor In the Editor select Tools and then References Confirm that CBCOMDevkKit is selected in the list In the Project Explorer select Module1 for Toledo Gas xls a 5 Y N Study the code annotations for examples of how to perform basic Predictor operations Notice that code illustrating the event feature and ARIMA time series forecasting is included As you study the code annotations refer to basic code strategies outlined in Coding an Optimization on page 285 Although this information refers to the OptQuest Developer Kit basic rules and guidelines apply to the Predictor Developer Kit Note Although coding is similar in the OptQuest and Predictor Developer Kits ignore the sections on user defined event macros and events in VBA The Predictor Developer Kit does not support user defined events 298 Using the Predictor Developer Kit A B C D E F G H M N OP R S TU VW Index Symbols NET Framework version 278 295 Numbers 2D Simulation tool 184 246 247 A about dialog CB 50 AfterIterationEvent 290 AfterOptimizationEvent 290 AftersimulationEvent 289 alert macros 51 52 applications custom 209 assumptions correlating 86 88 custom 116 defining 112 113 117 defining parameters 109 enumerating 126 128 fitting distribu
175. e Description For Index 1 cbSceChooseTarget A cell reference with Variant n a Specifies the target forecast cell to be format Range A1 A1 or analyzed NT For Index 2 cbSceSelectPercentiles Integer 3 Indicates that a range of percentiles cbSceRangeForecastResults should be worked on For Index 2 cbSceSelectForeValues Integer 4 Indicates that a range of forecast cbSceRangeForecastResults values should be worked on For Index 3 PercentileMin a numeric Double n a Specifies the minimum value of the cbSceSelectPercentiles value percentile range to work on the maximum is specified as Value2 For Index 4 ForeValueMin a numeric Double n a Specifies the minimum value of the cbSceSelectForeValues value forecast value range to work on the maximum is specified as va1ue2 For Index 5 cbSceForeOption cbSceShowDefinedFore Integer 1 Sets the forecast option to show charts for all defined forecasts while Scenario Analysis runs For Index 5 cbSceForeOption cbSceShowTargetFore Integer 2 Sets the forecast option to show only the chart for the target forecast while Scenario Analysis runs For Index 5 cbSceForeOption cbSceHideFore Integer 3 Sets the forecast option to hide charts for all forecasts while Scenario Analysis runs the fastest setting CB ScenarioAnalysisND 217 VBA Data Index Related Value Named Constant Value Type Value Description For Index 6 cbSceSimrTrials TrialRuns
176. e OptVarSolutionFilter This class represents the optimization variable statistics filter The statistics filter limits the set of solutions that affect the optimization variable statistics OptRuntime ResultsWindow This class represents the OptQuest Results window Its methods and properties control the display of optimization results OptRuntime RuntimeEfficientFrontier This class determines if an Efficient Frontier analysis was run and provides a variety of runtime information about test points and results Efficient Frontier allows users to create a variable list of constraint and requirement right hand side values using a list of test points OptRuntime TestPointinfo The methods and properties of this class summarize optimization information for a single Efficient Frontier test point OptQuest Developer Kit Use and Structure 281 Developing Optimization Code This section discusses the development environment resources available to help you learn and use the Optquest Developer Kit and an overview of how to start and continue coding an optimization with illustrations from sample code Development Environment For development with the OptQuest Developer Kit you can use any development environment that supports the use of Microsoft COM components Such an environment lets you use VB6 VBA supplied with Microsoft Word and Microsoft Excel C ASP and similar COM compatible languages you will still need the Microsoft NET F
177. e Type Value Description cbSceChooseTarget Integer 1 Selects the target forecast to be analyzed The range can either be specified as a separate line preceding the CB ScenarioAnalysisND call such as A1 C100 Select or it can be the va1ue1 parameter specified as A1 C100 or similar If the optional Va1ue1 parameter is not given the current active range is used 216 Crystal Ball Macro Calls VBA Data Index Named Constant Value Type Value Description cbSceRangeForecastResults Integer 2 Works with other Index constants used as Value1 to set Scenario Analysis to work with a percentile range or value range cbSceSelectPercentiles 3 cbSceSelectForeValues 4 cbSceSelectPercentiles Integer 3 Works with Va1ue1 and Value2 to specify a range of percentiles cbSceSelectForeValues Integer 4 Works with Value and Value2 to specify a range of forecast values cbSceForeOption Integer 5 Works with va1ue1 to indicate which forecast charts to show while running Scenario Analysis cbSceSimTrials Integer 6 Sets the number of trials to run cbScelncludeNonTargetFore Integer 7 When set to True includes all forecasts in the output table otherwise includes only the target forecast cbSceRun Integer 8 Runs the Scenario Analysis tool when all settings are complete Table 172 CB ScenarioAnalysisND Value1 Parameter Optional Variant VBA Data Index Related Value Named Constant Value Type Valu
178. e distribution type See Table 55 for types and associated parameters Parml Parm2 Double Double value or named Specifies the alternate parameters used to define the distribution You must Parm3 All are constant See Table 53 supply three parameters whether or not the distribution needs three That required following is ifa distribution uses only one or two parameters you must still supply three using the cbParmNone parameter to round out the argument list For more information see Table 53 Parm4 Variant Named constant or Specifies an optional fourth alternate parameter currently required only for Optional other value the beta distribution The following constant and index values shown in Table 53 can be used with Parmi Parm2 Parm3 and Parm4 described in Table 52 Table 53 CB DefineAltParms Parm1 Through Parm4 Constant and Index Values Named Constant cbParmNone 1 Index Value Description parameter Placeholder in the parameter list for distributions that require fewer than three parameters This parameter must come at the end of the argument list See the examples for how to use this CB DefineAltParms 109 Named Constant Index Value Description cbParmRegular 2 Regular parameter for the distribution for example the mean or standard deviation for the normal distribution You can t use this parameter for lognormal di
179. e format workbook sheet A 1 Value Variant Represents the correlation value associated with Assum1 and Assum2 by reference Notice that all parameters are by reference The values passed into CB EnumCorrelation are ignored The next set of enumeration values is assigned to the parameters when the function returns CB EnumCorrelation Example 1 This example uses asml Address to represent Assum1 uses asm2Address to represent Assum2 uses corrValue to represent Value and then uses a loop to stop execution when all correlated assumptions have been located As it runs it displays a message box with the first and second assumption in each pair of correlated assumptions along with the correlation value Sub EnumCorr Dim asmlAddress As String Dim asm2Address As String Dim corrValue As Variant Dim count As Variant CB CheckData When asmlAddress asm2Address and corrValue are passed ByRef the value passed into the function is ignored and the next set of values in the enumeration is set in these parameters when the call returns count CB EnumCorrelation asmlAddress asm2Address corrValue While count 0 MsgBox Assumption in cell amp asmlAddress amp _ is correlated to assumption in cell amp asm2Address _ by amp corrValue count CB EnumCorrelation asmlAddress asm2Address corrValue Wend End Sub CB EnumCorrelation 129 CB EnumCorrelation Example 2 This example uses asm1Address to
180. e number integer n a Used with cbTwoDOuterSimrTrials to indicate the number of trials in the outer uncertainty simulation For Index 4 cbTwoDInnerSim Trials Positive whole number integer n a Used with cbTwoDInnerSimTrials to indicate the number of trials in the inner variability simulation For Index 5 cbTwoDForeOption Integer cbTwoDShowDefineFore 1 Returned to indicate that all defined forecasts are displayed the equivalent of the Show Forecasts As Defined dialog setting For Index 5 cbTwoDForeOption Integer cbTwoDShowTargetFore 2 Returned to indicate that only the target forecast is displayed the equivalent of the Show Only Target Forecast dialog setting CB GetTwoDSimulationOption 185 Related Value Value or Named Constant Index Description For Index 5 cbTwoDHideFore 3 Returned to indicate that all forecasts are hidden the cbTwoDForeOption Integer equivalent of the Hide All Forecasts dialog setting For Index 6 cbTwoDShowForeStat 1 Returns a boolean Value2 parameter to indicate whether cbTwoDOutputOption Integer to include forecast statistics in the output report if followed by True includes statistics in the report For Index 6 cbTwoDShowPercentiles 2 Returns a boolean value2 parameter to specify whether cbTwoDOutputOption Integer to include percentiles in the output report if followed by True includes percentiles in the report For Index 6 cbTwoDSho
181. e obsolete since their functionality is replaced by the filtering constants in CB SetFore the constant cbStaCenterOn is obsolete because ranges are now always centered on Median and cbStaReversePercentile is obsolete because it is now handled in CB RunPrefsND Note To support the changes from CB RestoreRun and CB RestoreRunND to CB RestoreResults and CB RestoreResultsND the related constant returned from CB MacroResult has been changed from cbErrRestoreRun to cbErrRestoreResult The returned value is unchanged The following spreadsheet functions are not included in this version of the Crystal Ball Developer Kit CB ExtremeValue CB ExtremeValue2 CB GetCorrelationFN CB GetDecVarFN CB GetForeFN CB GetVersionFN Changes to Existing Calls This section lists macro calls that have changed since the 2000 5 5 5 version of the Crystal Ball Developer Kit and describes the changes In the following updates constant index numbers are indicated in square brackets For example cbCelDistMedian 5 means constant cbCelDistMedian with index number 5 When constants are labeled deprecated they are currently accepted for compatibility but become obsolete in a future version and should not be used in new code Changes to Existing Calls 257 CB AssumPrefsND e Documentation errors corrected the first parameter is renamed PrefItem and the index number for constant cbAssumShowMean is changed from 2 to 3 to match the code e The constant
182. e than one trend chart is defined and no chart is selected this call returns an error Note Before calling CB TrendPrefsND run a simulation Table 205 Parameters for CB TrendPrefsND Parameter VBA Data Type Value Description Index Integer See Table 206 Works with the other parameters to set trend chart preferences Valuel Variant See Table 207 Works with the other parameters to set trend chart preferences Value2 Optional Variant See Table 208 Works with the other parameters to set trend chart preferences Value3 Optional Variant See Table 209 Works with the other parameters to set trend chart preferences Value4 Optional For Index 8 Any integer between O and Sets a fourth certainty band to display Use this with va1ue1 Integer 100 inclusive through Value3 CB TrendPrefs 243 Parameter VBA Data Type Value Description Value5 Value6 Integer Any integer between O and Sets up to three more certainty bands to display Use this with Value All 100 inclusive Value1 through Value4 optional Table 206 following describes the Index parameter Table 206 CB TrendPrefsND Index Parameter Values Required Integer Named Constant Value Index Value Description cbTrdTitle 1 Gives the trend chart a title as defined by va1ue1 cbTrdChooseFore 2 Clears and selects the forecasts for the trend chart according to va1ue1 cbTrdVertGridLines 4 Turns on and off the vertical
183. e to be used as input for CB Fit CB SetFore on page 232 Changes the settings for a forecast CB SetRange on page 235 Sets the certainty range for one or all forecasts CB Shutdown on page 237 Closes Crystal Ball while leaving Microsoft Excel open CB SimResult on page 237 Returns criteria that stopped the last simulation CB Simulation on page 238 Runs a simulation for the specified number of iterations CB SingleStep on page 240 Runs one trial of a simulation changing assumptions once CB StartMultiSimul on page 240 Marks the start of multiple simulations Alphabetic List of Crystal Ball Macro Calls 37 Name Description CB Startup on page 242 Loads Crystal Ball into Microsoft Excel if possible and indicates when Crystal Ball has been successfully opened CB StopMultiSimul on page 242 Marks the end of multiple simulations CB TrendPrefs on page 243 Opens the Trend Preferences dialog for the selected trend chart CB TrendPrefsND on page 243 Sets preferences for the specified trend chart CB TwoDSimulation on page 246 Launches the 2D Simulation tool CB TwoDSimulationND on page 247 Runs the 2D Simulation tool without showing dialogs CB WorksheetProtection on page 250 Enables and disables worksheet protection for the active worksheet Spreadsheet Models Functions For Use in Microsoft Exc
184. e which decision variable s address to return cbDecSimOption 3 Used with Index2 to return the number of test values for the specified decision variable or the maximum number of trials for the simulation cbDecForeOption 4 Returns the current forecast chart display setting 1 Show Forecasts As Defined set with cbDecShowDefinedFore 2 Show Only Target Forecast set with cbDecShowTargetFore 3 Hide All Forecasts set with cbDecHideFore Table 118 CB GetDecisionTableOption Index2 Parameter Optional Integer Index Named Constant Value Value Description cbDecVar1 1 Used with cbDecGetDecVar to return the address of the first selected decision variable in the format workbook sheet A 1 cbDecVar2 2 Used with cbDecGetDecVar to return the address of the second selected decision variable in the format workbook sheet A 1 cbDecNumValuesVar1 1 Used with cbDecSimOption to return the number of test values to use for the first selected decision variable cbDecNumValuesVar2 2 Used with cbDecSimOption to return the number of test values to use for the second selected decision variable cbDecSimTrials 3 Used with cbDecSimOption to return the maximum number of trials for each simulation CB GetDecisionTableOption Example The following example returns information for the Decision Table definition created in CB DecisionTableND Example and stores it in cells M6 through M12 Gets the address Gets
185. eValue 8 Sets the size of the confidence interval in forecast units according to Value cbForPrecisionRelativeValue 9 Sets the size of the confidence interval in percentage terms according to Value cbForPrecisionMean 10 Sets whether Crystal Ball uses the precision ofthe mean as a stopping criterion according to Value cbForPrecisionStdDev 11 Sets whether Crystal Ball uses the precision of the standard deviation as a stopping criterion according to Value cbForPrecisionPerc 12 Sets whether Crystal Ball uses the precision of a percentile value as a stopping criterion according to Value cbForPrecisionPercValue 13 Sets the percentile value that Crystal Ball checks for the indicated precision according to Value cbForFilter 14 Sets whether Crystal Ball filters forecast values according to Value cbForFilterlnside 15 Sets whether discards forecast values inside or outside the indicated range according to Value cbForFilterFrom 16 Sets the lower bound of the filtering range according to value cbForFilterTo 17 Sets the upper bound of the filtering range according to va1ue cbForFilterGlobal 18 Specifies whether Crystal Ball applies the filtering options to equivalent trials of all forecasts according to Value cbForFrozen 19 Freezes the forecast according to Value cbForLSL 20 Enters a lower specification limit for the forecast according to Value cbForUSL 21 Enters an upper specification limit for the forecast according to Value cbForTarget
186. ecified range CB CopyDataND Copies selected assumptions decision variables or forecasts CB PasteData Pastes assumptions decision variables or forecasts into selected cells 78 Crystal Ball Macro Calls CB CloseAllCharts Subtopics e CB CloseAllCharts Example e CB CloseAllCharts Related Calls This call closes all charts of any type It is the equivalent of the Analyze then Close All command This call works on both current and restored results CB CloseAllCharts Example This example runs a simulation and closes all open charts CB Simulation 1000 CB CloseAllCharts CB CloseAllCharts Related Calls Name Description CB CloseChart Closes the selected chart of the given type CB OpenChart Opens the selected chart of the specified type CB CloseChart Subtopics e CB CloseChart Example e CB CloseChart Related Calls This call closes a chart of the specified type and chart ID The chart ID is optional If the chart ID is not specified the currently selected chart is closed If the specified chart is not found a chooser dialog appears No error is returned Currently this call only works on current and not restored results Table 26 CB CloseChart Parameters VBA Data Parameter Type Value Description SimChartType Integer cbChtOverlay 1 cbChtScatter Specifies the type of chart you are closing overlay scatter 2 cbChtSensitiv 3 sensitivity or trend chart For named consta
187. ed while all unlisted cells are frozen False The default is True The following table shows named constant and index values for the Index parameter Table 85 CB FreezeND Index Parameter Values Required Integer Named Constant Value Index Value Description cbFrzAddCell 1 Adds the selected cell to the list of frozen or enabled cells cbFrzClearlist 2 Clears the list of frozen or enabled cells added with cbFrzAddCell cbFrzSetList 3 Depending on the value of the Frozen parameter indicates that the listed cells are frozen True or the reverse enabled False The default is False This constant must be called after cbFrzAddCell to activate the freeze See CB FreezeND Example following CB FreezeND Example This example clears the list builds a list to freeze and then freezes it Sub FreezeNDExample Clear the list to Freeze Unfreeze upfront to insure you are starting from a clean selection state CB FreezeND cbFrzClearList Build list to Freeze 2 variables in cells Al A2 Range A1 Select CB FreezeND cbFrzAddCell 148 Crystal Ball Macro Calls Range A2 Select CB FreezeND cbFrzAddCell Freeze selected CB variables CB FreezeND cbFrzSetList True Run Simulation with Frozen variables custom logic CB Simulation 100 CB ResetND Unfreeze selected variables CB FreezeND cbFrzSetList False At this point you can either call CB FreezeND CB cbFrzClear
188. ee Chapter 3 Crystal Ball Macro Calls Installing Crystal Ball Runtime To install your custom applications and Crystal Ball with a Runtime license instruct users to 1 Set Microsoft Excel macro security to Medium recommended or Low using the following command sequence in Microsoft Excel Tools then Options then Security and then Macro Security In Microsoft Excel 2007 or later click the Office button and click Excel Options Then check Show Developer Tab In The Ribbon and click OK On the Developer tab choose Macro Security Then check Disable all macros with notification recommended or Enable all macros not recommended potentially dangerous code can run Note If you have attached a digital signature to the application xls or xla files this step is not necessary 274 Crystal Ball Runtime SSS 2 Unzip your application Crystal Ball bundle by double clicking or other procedure depending on how it is constructed 3 Activate the installation and licensing scripts Launch the application which should then launch Microsoft Excel and Crystal Ball From then on the application should be self documenting with clearly labeled controls text boxes messages and prompts to guide users through the application workflow Note These instructions assume that your application sets a reference to cbdevkit xla To do this start Microsoft Excel and select Tools then Macros and then Visual Basic Editor Then select
189. een Crystal Ball and your application It consists of a library of macro calls subroutines and functions that control many aspects of Crystal Ball Each copy of Crystal Ball comes enabled to use the Developer Kit so that programs you develop today can be run by other users as well This kit is the key that unlocks the programmability of Crystal Ball and guides you through the many calls available In addition to the descriptions of the calls or subroutines and functions this manual contains examples that illustrate usage of the Developer Kit in several practical applications You are encouraged to study these examples before starting out on your own applications Should you need additional help technical support is available with appropriate licenses About the Oracle Crystal Ball Developer Kit 21 Note Feature automation in Oracle Crystal Ball Decision Optimizer and the Predictor feature of Crystal Ball is implemented in a different way Automation of the Crystal Ball Tornado Analysis tool is handled the same way For general information see Appendix B Using the Predictor Developer Kit It discusses the structure of the developer kit that can be used with the Tornado Analysis tool and describes example files that can be opened within Crystal Ball to explain the use of that developer kit Tornado Analysis automation is described in Reliability with Dev Kit xls If you have Crystal Ball Decision Optimizer Appendix A Using the OptQue
190. eferences e Set chart preferences e Set cell attribute preferences The subroutines and functions described in the following sections are used to set and get preferences e CB AssumPrefsND on page 53 e CB CellPrefs on page 68 e CB CellPrefsND on page 69 e CB ChartPrefs on page 71 e CB ChartPrefsND on page 72 e CB FormatPrefs on page 144 e CB FormatPrefsND on page 145 e CB GetExcel2007ForegroundMode on page 169 e CB GetRunPrefs on page 181 e CB RunPrefs on page 204 e CB RunPrefsND on page 204 e CB ScatterPrefs on page 211 e CB ScatterPrefsND on page 212 e CB SensPrefs on page 221 e CB SensPrefsND on page 222 e CB SetExcel2007ForegroundMode on page 230 e CB TrendPrefs on page 243 e CB TrendPrefsND on page 243 The following calls affect sensitivity charts although they are not strictly preferences e CB GetAsmSensitivityChartGroup on page 149 e CB SetAsmSensitivityChartGroup on page 224 Setting and Getting Preferences 43 Crystal Ball Tools The macro calls described in the following sections are used to launch Crystal Ball tools access tool functionality without displaying dialogs or return information about tool settings CB BatchFit on page 54 CB BatchFitND on page 55 CB Bootstrap on page 63 CB BootstrapND on page 63 CB DataAnalysis on page 101 CB DataAnalys
191. el Table 2 Functions For Use in Microsoft Excel Models on page 38 lists Crystal Ball functions that are also available as spreadsheet functions for use in Microsoft Excel spreadsheet models To use these functions with Crystal Ball loaded 1 Select an empty spreadsheet cell and select Insert and then Function In Microsoft Excel 2007 or later select Formulas and then Insert Function 2 Select the Crystal Ball category in the category list box 3 Find the function in the function list Select it and click OK Always select the function ending in FN since the other runs significantly slower in most cases 4 In the Function Arguments dialog enter any required arguments and click OK The requested value is displayed in the cell with the function Be sure to save the workbook with the new function while Crystal Ball is open Note CB GetForeStatFN only pulls N 1 trials during a recalculation for either a single step or a full simulation but will reflect full trials at the end of the single step or full simulation since a final recalculation is always performed Table 2 Functions For Use in Microsoft Excel Models Name CB GetAssumFN Description Retrieves information for a specific assumption cell See CB GetAssum on page 150 CB GetAssumPercentFN Returns the value corresponding to a percentile for an assumption cell See CB GetAssumPercent on page 152 38 Crystal Ball Developer Kit
192. ell CB DefineDecVar Example This example selects cell B5 a single value cell and then opens the Define Decision Variable dialog so you can define or redefine a decision variable CB ResetND Range B5 Select CB DefineDecVar CB DefineDecVar Related Calls Name Description CB DefineDecVarND Defines or changes the decision variable in a selected cell without using a dialog CB DefineDecVar 119 Name CB GetDecVar Description Retrieves information for a specific decision variable cell CB SetDecVar Changes certain attributes for a decision variable CB DefineDecVarND This subroutine defines or changes a decision variable in the selected cell without using a dialog If a simulation runs before this subroutine is used the simulation must be reset before the decision variable is defined Note Before calling this subroutine select a cell Table 57 CB DefineDecVarND Parameters VBA Data Parameter Type Value Description Min Variant Any positive or negative Specifies the minimum lower bound of the decision variable Must be number an integer for the Category decision variable type ignored for decision variable types Binary and Custom Max Variant Any positive or negative Specifies the maximum upper bound of the decision variable Must number equal to or greater be an integer for the Category decision variable type ignored for decision than Min variable types Binary
193. er Optional Variant VBA Data Related Value Named Constant Value Type Description For Index2 cbDecNumValuesVar1 or A positive whole number Integer Specifies the number of test values to use for cbDecNumValuesVar2 Integer each selected decision variable For Index2 cbDecSim Trials Long Integer A positive whole number Long integer Specifies the maximum number of trials for each simulation CB DecisionTableND Example This example resets the simulation defines cell B5 as the target forecast with cells C1 and C2 as the first and second decision variables Then it specifies the number of test values to use for each of the two decision variables 7 and 10 respectively sets 500 as the maximum number of trials to run and indicates that forecast charts are to be hidden while the simulation is running The final line runs the tool CB ResetND Select a target forecast Range B5 Select CB DecisionTableND cbDecChooseTarget Clear the list of any previously selected decision variables CB DecisionTableND cbDecChooseDecVar cbChdClearList Select decision variables cells C1 and C2 Range C1 Select CB DecisionTableND cbDecChooseDecVar cbChdAdd Range C2 Select CB DecisionTableND cbDecChooseDecVar cbChdAdd Set number of values to test for DecVarl in cell C1 CB DecisionTableND cbDecSimOption cbDecNumValuesVarl 7 Set number of values to test for DecVar2 in cell C2 CB DecisionTableND
194. er Table 142 on page 183 Valuel Optional Double Table 143 on page 183 The Index parameters Table 142 on page 183 are the same as those used to make the Scenario Analysis settings Table 142 CB GetScenarioAnalysisOption Index Parameter Required Integer VBA Data Index Named Constant Value Type Value Description cbSceChooseTarget Integer 1 Returns the target forecast cell to be analyzed cbSceRangeForecastResults Integer 2 Returns whether percentiles or forecast values are to be used for the analysis cbSceSelectPercentiles 3 cbSceSelectForeValues 4 cbSceSelectPercentiles Integer 3 Works with va1ue1 to return the minimum or maximum of the range of percentiles used for analysis if percentiles were used cbSceSelectForeValues Integer 4 Works with va1ue1 to return the minimum or maximum of the range of forecast values used for analysis if forecast values were used cbSceForeOption Integer 5 Returns the current Scenario Analysis Options setting that indicates which forecast charts to show while running Scenario Analysis cbSceShowDefinedFore 1 cbSceShowTargetFore 2 or cbSceHideFore 3 Table 172 on page 217 cbSceSimTrials Integer 6 Returns the number of trials to run cbScelncludeNonTargetFore Integer 7 When True is returned indicates that all forecasts are included in the output table if False only the target forecast is included Table 143 CB GetScenarioAnalysisOption V
195. es 220 sensitivity chart grouping assumptions 149 224 sensitivity charts closing 81 copying 85 customizing 221 222 opening 198 setting certainty ranges 235 showing the OptQuest wizard 287 simulation results restoring 202 203 saving 210 simulations resetting 201 restoring results 203 running 238 running multiple 240 A B C DEF single steps 240 stopping criteria 237 stopping multiple 242 trial number 190 single steps 240 Spearman rank order correlation 67 spreadsheet functions in Crystal Ball 38 starting Crystal Ball 67 160 227 242 statistics getting CB forecast 177 getting from assumptions 154 stopping multiple simulations 242 simulations 237 subroutine 23 support resources 23 system requirements 22 278 T technical support 23 terms 23 tools 106 158 2D Simulation 184 246 247 Batch Fit 54 55 155 Bootstrap 63 Data Analysis 101 102 164 DecisionTable 166 Scenario Analysis 182 215 216 Tornado Analysis automation 22 Tornado Analysis example 22 training 23 trend charts closing 82 copying 86 customizing 243 opening 199 trials 190 trials running one 240 U unloading Crystal Ball 237 user defined event macros 287 user defined macros 28 V values default 32 G L M N OP R S TU VW variables decision attributes 228 decision defining 119 120 decision selecting 220 enumerating decision 130 retrieving decision inform
196. es are used with Index cbExtStartSheet to specify whether data should be extracted to a new or existing workbook and worksheet Note Calling ExtractDataND with cbExtStartSheet will overwrite any settings made with cbExtExistingSheet Table 74 Value Parameter Values that Support Index Constant cbExtStartSheet Named Constant Value Index Value Description cbExtNewWorkbook 1 Extracts the results to a new workbook using the cbExtSheetName value as the name of the sheet cbExtCurrentWorkbook_NewSheet 2 Extracts the results to the current workbook using the cbExtSheetName value as the name of the sheet cbExtCurrentWorkbook_ 3 Extracts the results to the current workbook s current sheet CurrentSheet The following values are used with Index cbExtDataOptimizerType to specify which optimizer data should be extracted to the specified location A third boolean value True or False is used to activate or deactivate the preceding entries Table 75 Value Parameter Values for Index Constant cbExtDataOptimizerType Named Constant Value Index Value Description cbDatOptimizerSolutions 1 Extracts OptQuest solution information cbDatOptimizerStatistics 2 Extracts OptQuest statistical information The following values are used with Index cbExtChooseDecVar to specify decision variable data for extraction If not specified the current setting from the Extract Data dialog is used Table 76 Value Parameter Values that
197. essibility Program website at http www oracle com pls topic lookup ctx acc amp id docacc Access to Oracle Support Oracle customers have access to electronic support through My Oracle Support For information visit http www oracle com pls topic lookup ctx acc amp id info or visit http www oracle com pls topic lookup ctx acc amp id trs if you are hearing impaired 19 20 Documentation Accessibility Welcome In This Chapter About the Oracle Crystal Ball Developer Kit oooococococccococoncccccnononcnononennnrna narra nenas 21 Who Should Use the Crystal Ball Developer Kit o oooococccoccccccncnononononcncnrnn nana nano 22 What You b I 22 How This Mantal is Organized carci en eae LECHE ee 22 Documentation GMan mU 23 Technical Support ana MoE o a AN 23 About the Oracle Crystal Ball Developer Kit Welcome to the Developer Kit for Oracle Crystal Ball Using the Crystal Ball Developer Kit you can automate and control Crystal Ball simulations from within a Visual Basic for Applications VBA program This opens up a whole range of possibilities e Running multiple simulations to test different sets of assumptions automatically e Integrating Crystal Ball with other software tools e Creating turnkey applications that shield users from program intricacies e Building custom reports or automate post simulation analysis e Setting up specialized simulation environments The Developer Kit provides a link betw
198. esult lock the Location parameter of the gamma distribution clear any previous values from the Shape parameter of the gamma distribution run the fit and return results Notice that CB SetFitRange is used before CBLockFitParm Dim Result as Double Define a range of data for fitting CB SetFitRange A1 A30 Lock the Location of Gamma to 0 CB LockFitParm cbDfaGamma True 1 O Clear any locked values for the Shape of Gamma CB LockFitParm cbDfaGamma True 3 cbParmUndefined Run the fit and return the result Result CB Fit cbDfaGamma cbFitAndersonDarling False CB LockFitParm Related Calls Name Description CB Fit Fits a specific probability distribution to a selected set of data range of cells CB GetFitParm Returns the value of the specified distribution parameter for the last CB Fit call CB GetLockFitParm Returns whether a distribution and optionally specific parameters have locked values for fitting purposes CB SetFitRange Specifies the data range to be used as input for CB Fit CB MacroResult This function returns information about whether other Crystal Ball macro calls worked correctly Most of the calls described in this document set a result value that CB MacroResult returns CB MacroResult does not clear the result value until another Crystal Ball call changes the value 192 Crystal Ball Macro Calls a Table 157 CB MacroResult Returned Data Type Returned Value Returned Data Type
199. et forecast the equivalent of the cbTwoDForeOption Integer Show Only Target Forecast dialog setting For Index 5 cbTwo ForeOption cbTwoDHideFore 3 Hides all forecasts the equivalent of the Hide All Integer Forecasts dialog setting For Index 6 cbTwoDShowForeStat 1 Used with cbTwoDOutputOption and a boolean value cbTwoDOutputOption Integer parameter to specify whether to include forecast statistics in the output report if followed by True includes statistics in the report For Index 6 cbTwoDShowPercentiles 2 Used with coTwoDOutputOption and a boolean value cbTwoDOutputOption Integer parameter to specify whether to include percentiles in the output report if followed by True includes percentiles in the report For Index 6 cbTwoDShowCapMetrics 3 Used with cbTwoDOutputOption and a boolean value cbTwoDOutputOption Integer parameter to specify whether to include capability metrics in the output report if followed by True includes capability metrics in the report For Index 7 cbTwoDPercent cbTwoDPercentTenNinety 1 Specifies the 10th and 90th percentiles Integer For Index 7 cbTwoDPercent cbTwoDPercentFiveNinetyFive 2 Specifies the 5th and 95th percentiles Integer For Index 7 cbTwoDPercent cbTwoDPercentQuartiles 3 Specifies quartiles 25 ile increments from O to 100 Integer inclusive 248 Crystal Ball Macro Calls Related Value Value or Named Constant Index Description For Ind
200. ether the data range has labels If set to True there is label text in the first column or top row depending on the cbBftInputOrientation setting For Index b cbBftSelectDist cbDfa from Table 79 Integer 0 23 50 53 Indicates a specific distribution or distribution type s to fit to the data For Index 11 cbBftRankMethod Methods listed in Integer 1 5 Specifies a ranking method as listed in Table 80 Table 80 For Index 12 cbBftNewWorkbook Integer 1 Used with va1ue2 to indicate whether cbBftOutputLocation results should go in a new workbook For Index 12 cbBftNewWorksheet Integer 3 Used with Value2 to indicate whether cbBftOutputLocation results should go in a new worksheet CB BatchFitND 57 VBA Data Related Value Named Constant Value Type Index Value Description For Index 13 True or False Boolean n a Indicates whether results should be cbBftOutputFormat formatted if True formatting is applied For Index 14 True or False Boolean n a Indicates whether to create a correlation cbBftOutputCorrelationMatrix matrix if True the matrix is produced For Index 16 True or False Boolean n a Indicates whether to link to the matrix of cbBftLinkToCorrelationMatrix correlations between the data series if True creates the link For Index 17 True or False Boolean n a Indicates whether to output a goodness cbBftOutputGoodness OfFitReport of fit report if True
201. eturns the name of the worksheet containing primary fit results assumptions as a string e See CB BatchFitND on page 258 for two Index constants removed in version 11 1 2 3 500 CB GetCertainty e The first parameter is now named ForeReference with a data type of Variant CB GetCorrelation e To correct a documentation error the first parameter is now named AssumReference with a data type of Variant e The Row parameter data type is now Long Changes to Existing Calls 265 CB GetDecVar To correct a documentation error the first parameter is now named DecVarReference with a data type of Variant A new constant is added for the Index parameter cbDecFrozen 6 Starting with Crystal Ball 11 1 1 0 00 the cbDecType 4 constant now returns five types Continuous 0 Discrete 1 Binary 2 Category 3 Custom 4 Also a new constant cbDecCustomData 7 is added to the Index parameter for use when cbDecType 4 indicates a Custom 4 type Starting with Crystal Ball 11 1 2 0 00 anew constant cbDecCustomDataCount 8 is added to the Index parameter for use when cbDecType 4 indicates a Custom 4 type CB GetFitParm A fourth Index value is added to support the 7 x and 11 x beta distribution The parameters for beta have changed since 2000 x 5 x A fourth Index value is added to support the 7 x and 11 x beta distribution The extreme value constant is deprecated It is included for Crystal Ball 2000 5 5 5
202. ex 7 cbTwoDPercent cbTwoDPercentQuintiles 4 Specifies quintiles 20 ile increments from O to 100 Integer inclusive For Index 7 cbTwoD Percent cbTwoDPercentDeciles 5 Specifies deciles 10 ile increments from O to 100 Integer inclusive For Index 7 cbTwoDPercent cbTwoDPercentlcosatiles 6 Specifies icosatiles 596 ile increments from O to 100 Integer inclusive For Index 7 cbTwoDPercent cbTwoDPercentCustom 7 Defines custom percentiles supplied by an optional Integer Value entry a one dimensional cell range containing percentiles If value is omitted the default percentiles are 2 5 5 50 90 95 97 5 For Index 8 Integer from 2 to 250 n a Used with coTwoDMSDOption to specify the maximum cbTwoDMSDOption Integer number of uncertainty simulations to display in the output report and overlay chart Table 213 CB TwoDSimulationND Value2 Parameter Optional Variant VBA Data Related Value Value or Named Constant Type Index Description For Index 6 True or False Boolean n a Indicates whether to activate the cbTwoDOutputOption Integer specified va1ue1 constant if set to True includes the specified items in the output report For Valuel A string containing a Microsoft Excel String n a Specifies custom percentile values to cbTwoDPercentCustom range that holds desired percentile analyze values The values must be entered into Microsoft Excel as numbers not formatted as percentages can be decim
203. extreme and minimum extreme distributions cbParmMode is deprecated in this version of Crystal Ball and is obsolete in a future version 110 Crystal Ball Macro Calls CB DefineAltParms Example 1 This example defines the assumption in cell B5 as a normal distribution using the mean and standard deviation Because the normal distribution requires only these two parameters use cbParmNone to stand in as the third unused parameter in the argument list CB DefineAssumND receives this information about the distribution and parameter set and defines the assumption s distribution with a mean of 10 and a standard deviation of 0 2 Range B5 Select Value CB DefineAltParms cbDfaNormal cbParmMean cbParmStDev coParmNone CB DefineAssumND Value 10 0 2 CB DefineAltParms Example 2 This example defines the assumption in cell B6 as a normal distribution using the 10th and 90th percentiles The 10th percentile is 10 the 90th percentile is 12 and cbParmNone is a placeholder in the argument list Range B6 Select Valuel CB DefineAltParms cbDfaNormal cbParmPercentile 10 _ cbParmPercentile 90 cbParmNone CB DefineAssumND Valuel 10 12 Note If you use the numeric value of the index instead of the constant name for cbParmPercentile as in Example 3 you must use the sample syntax 0 percentile so that the function can identify the parameter by the numeric value CB DefineAltParms Example 3 This example select
204. fFillDown Boolean True or False If True the default fills parameter reference cells down if False fills them Optional to the right moving from lower to higher columns ParmRefLabel Boolean True or False If True includes parameter name labels adjacent to parameter value cells Optional for all referenced parameters default is False TruncateCustom Boolean True or False When defining an assumption from a forecast using the Crystal Ball user Optional interface if the forecast trial count exceeds 5 000 users are prompted to use the first 5 000 trials or all trials This constant is the equivalent of the prompt if True the first 5 000 trials are used if False the default all trials are used SequentialCustom Boolean True or False If True defines a sequential custom distribution retaining generated Optional forecast value order default is False CB DefineAssumFromForeND Example The following example creates an assumption with a gamma distribution creates a forecast with those parameters runs a simulation and then defines an assumption from the forecast It then defines a custom distribution from the forecast and retains the sequence of values for sequential sampling Sub DefineAssumptionFromForecast Define a Gamma distribution assumption and forecast to fit A1 Select CB DefineAssumND cbDfaGamma 0 1 2 B1 A1 B1 Select CB DefineForeND Forecast to Fit Run 1000 trial si
205. fined Event Macro Names Users can create Microsoft Excel VBA event macros for workbooks Depending on the event selected Crystal Ball runs them automatically at various points in a simulation or optimization The original simulation specific macros are described in Chapter 4 of the Crystal Ball User Manual Beginning with Crystal Ball 11 1 1 0 00 macros based on VBA events are now available to run at various points during an OptQuest optimization Table 215 following summarizes events that can be defined with VBA code and describes when they run Note Event macros must be attached to worksheets or workbooks and not modules Table 215 Events Accessible through VBA and When They Run within an Optimization Event Type Runs BeforeOptimizationEvent Optimization Atthe start of an optimization when the OptQuest Run command is given or an equivalent command is given using the OptQuest Developer Kit BeforelterationEvent Optimization Atthe start of each iteration of an optimization just after the decision variable values for that iteration have been written to the workbook but before any nonlinear constraints have been evaluated by OptQuest BeforeSimulationEvent Simulation On each iteration of an optimization just before the simulation begins At this point nonlinear constraints have been evaluated by OptQuest AfterSimulationEvent Simulation On each iteration of an optimization just after the simulation completes Any
206. fined Predictor report available following a Predictor forecasting run With Index set to cbRptSection you can use the following constants as the Value2 parameter to specify the order of report sections see Table 42 Table 42 For Index cbRptSection Value2 Values Optional Integer Named Constant Value Index Value Description cbRptSectSummary 1 Includes the summary section cbRptSectOverlay 2 Includes the overlay chart section cbRptSectTrend 3 Includes the trend chart section cbRptSectSensitivity 4 Includes the sensitivity chart section cbRptSectScatter 5 Includes the scatter chart section cbRptSectForecasts 6 Includes the forecasts section cbRptSectAssumptions 7 Includes the assumptions section cbRptSectDecVars 8 Includes the decision variables section cbRptSectOptimizerResults 9 Includes the OptQuest results section following an OptQuest optimization run CB CreateRptND 99 Named Constant Value Index Value Description cbRptSectPredictorSeries 10 Includes the Predictor results section following a Predictor forecasting run With Index set to cbRptPredictorMethods you can use the following constants as the Value1 parameter to specify which forecasting methods to include in Predictor report data see Table 43 Table 43 For Index cbRptPredictorMethods Value1 Values Optional Integer Named Constant Value Index Value Description cbPredictorMethod
207. fines a new assumption from an existing forecast and places it in a specified cell without using a dialog For easiest use review the section on defining assumptions from forecasts in the Oracle Crystal Ball User s Guide A simulation must run before this call is used Table 56 CB DefineAssumFromForeND Parameters VBA Data Parameter Type Value Description ForeReference Variant A Microsoft Excel Specifies the forecast cell to be used to define the assumption cell range Range B3 AssumReference Variant A Microsoft Excel Specifies the desired location for the new assumption cell range Range B3 CB DefineAssumFromForeND 117 VBA Data Parameter Type Value Description ForeDistType Integer Integer value or Specifies whether the distribution type is determined by fitting to the named constant forecast distribution using current fit options set with the user interface or CB Fit or is a custom distribution Values can be e cbAsmFromFstDistTypeBestFit 1 best fit distribution parameters or e cbAsmFromFstDistTypeCustom 2 custom distribution from forecast values Nameof Optional String Title surrounded by Optional name to use for the new assumption can be a valid cell address quotes such as A1 to define a cell reference for the name UseParmRef Optional Boolean True or False If True creates cell references in the worksheet for distribution parameters default is False ParmRe
208. folio Analysis xls model set up an optimization manually and then run it You will then understand the manual process and can better follow what the code is doing The following sections discuss optimization coding strategies e Starting Out on page 285 e Continuing on page 286 e Error Handling on page 286 e Accessing OptQuest with the Crystal Ball Developer Kit on page 286 Note Before you begin coding you should learn to perform optimizations with OptQuest Many of the items used in OptQuest such as constraints and objectives match the corresponding objects in the OptQuest Developer Kit See the Oracle Crystal Ball Decision Optimizer OptQuest User s Guide for complete descriptions of the optimization process and items Starting Out The sample code in OptDevKitRuntimeSample xls begins by explicitly declaring variable types for several variables Option Explicit Private WithEvents PortfolioOptRuntime As CBCOMDevKit OptRuntime Private PortfolioOptSetup As CBCOMDevKit OptSetup Private ObjectiveTotal As CBCOMDevKit Objective Private RequirementRisk As CBCOMDevKit Requirement Private ConstraintFunds As CBCOMDevKit Constraint Private DecisionFundl As CBCOMDevKit Decision Private PortfolioWorkbook As Workbook Private InvestmentModel As Worksheet Private Options As CBCOMDevKit OptOptions Next it opens the subroutine that actually performs the optimization and defines error handling Sub RunOptimiza
209. forecasts with underlying data are actually extracted The others are ignored cbChfClearList 5 Clears the list of chosen forecasts The following values are used with Index cbExtPercentiles to specify percentile data for extraction Table 72 Value Parameter Values that Support Index Constant cbExtPercentiles Named Constant Value Index Value Description cbPctQuartiles 1 Extracts quartiles 2596 cbPctQuintiles 2 Extracts quintiles 2096 cbPctDeciles 3 Extracts deciles 1096 cbPctlcosatiles 4 Extracts icosatiles 596 cbPctSet1 5 Extracts 2 5 5 50 95 97 5 iles cbPctSet2 6 Extracts 10 25 50 75 90 iles cbPctSet3 7 Extracts the 5 and 95 percentiles cbPctSet4 8 Extracts the 10 and 90 percentiles The following values are used with Index cbExtChooseAsm to specify assumption data for extraction Table 73 Value Parameter Values that Support Index Constant cbExtChooseAsm Named Constant Value Index Value Description cbChaAll 1 Includes all assumptions cbChaChosen 2 Includes chosen assumptions Run this option after adding assumptions cbChaAdd 3 Adds the assumption in the selected cell to the chosen assumptions Use cbChaChosen after this option CB ExtractDataND 137 Named Constant Value Index Value Description cbChaClearList 4 Clears the list of chosen assumptions cbChaOpen 5 Includes all open assumptions The following valu
210. g Chart ID User defined or default chart name title entered directly Optional CB CreateChart Example This example creates an overlay chart a trend chart and a sensitivity chart and names each with the names in quotes ChartID ChartID ChartID CB CreateChart cbChtOverlay CB CreateChart cbChtTrend CB CreateChart cbChtSensitiv CB CreateChart Related Calls Overlay Chart 1 Trend Chart 1 Sensitivity Chart 1 Name CB CheckData Description Checks decision variables for validity initializes variables CB EnumChart Returns the unique name of the next chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB CreateRpt This subroutine creates a Crystal Ball report It opens the Create Report dialog that enables you to select report options and create a report Use CB CheckData before using this call CB CreateRpt Example This example opens the Create Report dialog so you can include assumptions decision variables forecasts and charts CB CreateRpt 91 CB Simulation 1000 CB CheckData CB CreateRpt CB CreateRpt Related Calls Name CB CreateRptND Description Sets report preferences and creates a report from the current simulation and restored results optimization or time series forecast without a dialog CB ExtractData Extracts data from the current simulation and restored results optimization or time
211. g options 100 samples with 1000 trials per sample CB BootstrapND cbBtsSample cbBtsNumberSamples 100 CB BootstrapND cbBtsSample cbBtsTrialsPerSample 1000 Set display settings to show only the target forecast CB BootstrapND cbBtsForeOption cbBtsShowTargetFore Run Bootstrap CB BootstrapND cbBtsRun CB BootstrapND Example 2 This example runs the Bootstrap tool using default preferences or settings from a previous run in the current Microsoft Excel session CB ResetND Run Bootstrap CB BootstrapND cbBtsRun CB BootstrapND Related Calls Name Description CB Bootstrap Launches the Bootstrap tool CB GetBootstrapOption Returns current settings for the Bootstrap tool 66 Crystal Ball Macro Calls CB CalculateSpearman This function returns the Spearman rank correlation or rank order correlation r between two sets of values This correlation is a nonparametric measure of dependence that ranges from 1 0 to 1 0 inclusive which assess how well the relationship between two values can be described using a monotonic function This function helps with the construction of a rank order coefficient matrix in a spreadsheet suitable for use by Crystal Ball Note To call this function from a worksheet use the name CB Spearman Table 18 CB CalculateSpearman Parameters Parameter VBA Data Type Description DataSeries1 Variant A Microsoft Excel range address or range name that contains the first se
212. g to Value cbAsmHighCutOff 7 Changes the higher truncation point according to Value Table 184 following describes the Value parameter Table 184 CB SetAssum Value Parameter Values Required Variant Used With Specified Values of Index Value Description For Index cbAsmName 1 String Assumption name in quotes Specifies the new assumption name For Index cbAsmLowCutOff 6 Double Any number Sets the new lower truncation point For Index cbAsmHighCutOff 7 Double Any number Sets the new upper truncation point CB SetAssum Example This example changes the name of the assumption in cell B3 to Revised Assumption CB SetAssum Range B3 1 Revised Assumption CB SetAssum Related Calls Name Description CB DefineAssumND Defines or changes assumptions in selected cells without using a dialog CB GetAssum Retrieves information for a specific assumption cell 226 Crystal Ball Macro Calls CB SetCBAutoLoad This call specifies whether to automatically start Crystal Ball whenever Microsoft Excel starts called autoloading The original default setting when Crystal Ball is first installed is False However the following alternatives can be used to activate autoloading using dialogs instead of the CB SetCBAutoLoad call e Start the Crystal Ball Application Manager and check or uncheck Automatically launch Crystal Ball when Microsoft Excel starts e Open the Mi
213. ger Required Named Constant Value Index Value Description cbCelAssum 1 Copies only assumption cell data cbCelFore 2 Copies only forecast cell data cbCelDecVar 3 Copies only decision variable cell data CB CopyDataND 83 Use this subroutine when the data range to copy has multiple Crystal Ball data types within the range This subroutine compared to CB CopyData pastes only the specified data type from a range with mixed cells Ifa range contains different Crystal Ball data types assumptions decision variables and forecasts then Crystal Ball will only copy the data type you specify with the DataType parameter Note Before calling this subroutine select a cell or cell range containing Crystal Ball data CB CopyDataND Example This example copies only the Crystal Ball assumption data from cells B5 and B6 Range B5 B6 Select contains an assumption and a forecast CB CopyDataND cbCelAssum CB CopyDataND Related Calls Name Description CB CopyData Copies Crystal Ball data in specified range CB PasteData Pastes assumptions decision variables or forecasts into selected cells CB CopyScatter Subtopics e CB CopyScatter Example e CB CopyScatter Related Calls This call copies the selected scatter chart to the clipboard If more than one chart is found but one is not selected a chooser dialog appears CB CopyScatter Example This example runs a simulation calls CB CheckData
214. ger number format For Index 1 cbFmtFormatType cbFttScientific 3 Sets the axis labels to appear in scientific notation Integer For Index 2 cbFmtUnderlying True or False n a True uses the underlying cell format overriding any other Boolean formatting previously set False uses General formatting For Index 3 cbFmtCommas True or False n a True uses commas or another thousands separator Boolean character in the axis labels False does not For Index 4 cbFmtDecimalPlace Any whole numberupto n a Sets the number of fixed decimal places This works only Integer 232 if you set the format type to cbFttFixed or cbFttScientific CB FormatPrefsND Example 1 This example selects a forecast cell turns off the underlying cell format preference in case it is on and then changes the format of the axis labels to be a fixed number of decimal places 3 Range B7 Select cb FormatPrefsND cbFmtUnderlying False cb FormatPrefsND cbFmtFormatType cbFttFixed cb FormatPrefsND cbFmtDecimalPlace 3 CB FormatPrefsND Example 2 This example sets the format of the axis labels for all the forecasts to use the underlying cell format This overrides any other format preference until you turn it off CB FormatPrefsND cbFmtUnderlying True True CB FormatPrefsND Related Calls Name Description CB ChartPrefs Sets chart preferences for the selected forecast or assumption using a dialog CB ChartPrefsND Sets chart preferences fo
215. get 1 Returns a string with the address of the target forecast in the format workbook sheet A 1 cbBtsGetDataRange 2 Returns a string with the address of the selected bootstrap data range in the format workbook sheet 1 A 1 2 100 cbBtsMethod 3 Returns the constant of the selected bootstrap method cbBtsMethodResample 1 or cbBtsMethodMultiSim 2 cbBtsAnalyze 4 Returns the constant of the selected analysis setting cbBtsAnalyzeStat 1 cbBtsAnalyzePercent 2 or cbBtsAnalyzeCapMetrics 3 cbBtsPercent 5 Returns the constant of the currently selected percentile setting for use if cbBtsAnalyze is called with cbBtsAnalyzePercent 2 cbBtsPercentTenNinety 1 cbBtsPercentFiveNinetyFive 2 cbBtsPercentQuartiles 3 cbBtsPercentQuintiles 4 coBtsPercentDeciles 5 cbBtsPercentlcosatiles 6 or cbBtsPercentCustom 7 If the returned value is cbBtsPercentCustom 7 you can use that constant as an Index2 parameter to return a range of custom values cbBtsSample 6 Used with Index2 to return the current bootstrap sample settings for cbBtsNumberSamples 1 or cbBtsTrialsPerSample 2 cbBtsForeOption T Returns the constant of the current forecast display setting cbBtsShowDefinedFore 1 cbBtsShowTargetFore 2 or cbBtsHideFore 3 Table 104 CB GetBootstrapOption Index2 Parameter Optional Integer Related Value For Index 5 cbBtsPercent Integer cbBtsPercentCustom 7 Named Constant Value Index Descripti
216. greed 268 AAA DEED isa ia Et iacet isi s o 268 GBSetaAs iungens bei Ea AERA XA REG GR Ra AA Ra Xa MR NR DER 269 CBSetDecVat 3d pd ad Beet eRe as ere ee 269 CB Set POP ccr 269 LE EU pi s dqeves nd uae a sees 269 CHS vespa viaria aida 270 CD Sap Lu Ga DU ut A AAA des 270 CB TrendPrefsND NUM node E es aS RN eos P 270 do JA 01 rsa ee re ee ee ee er ae eee ee re m 270 Charts Module cosoricoanosi carac 270 Chapter 5 Crystal Ball Runtime ooooo oo ooooooo nh 271 EEE aa a ri AAA AA ET 271 About Crystal Ball Runtime TER T sdei noes eee or or s Runtime Example Wome aia GR GE ERR AER DACIA ol a 271 Delivering Crystal Ball Runtime Applications 5 52 42 odes kae RR e 272 Installation Script re ee e ore ore er Sita NEL iaa eq sarda 4 a 1 AAA d 273 pls p oclo JP D Cnm 273 SUT SCP ood ba cda ET uda dria SAC ad ad spa 274 elias Ball Rate aed oo erc s E ERGu ERA Rte RE x ede EE s55 274 Crystal Ball Runtime Licensing Requirements cin cid EROR CROACIE ORO Re os 275 Appendix A Using the OptQuest Developer Kit BXGqGd qu CX rr Res PQ 277 About the OptQuest Developer Kit M Toce Pi ae Who Should Use This Kit n ves dba eri T TRE EN DIRE Lu aca cap ro RAO dee OE EORR ROS GIC ed 278 Wha rou WNEI MEE PET EUER 278 OpiQuest Developer Kit Use and Siyucture 242 22 usesuas he ade ratri 278 Specific Requi
217. grid lines according to va1ue1 cbTrdHorzGridLines 5 Turns on and off the horizontal grid lines according to Value1 cbTrdChartType 6 Sets the trend chart type according to Value1 cbTrdValueAxis 7 Sets options for the value axis according to Value1 cbTrdCertaintyBands 8 Sets up to 7 certainty bands to display according to va1ue1 through Value7 Note Index cbTrdForeTitleAxis 3 is now obsolete Table 207 following describes the Value1 parameter Table 207 CB TrendPrefsND Value1 Parameter Values Required Variant Used With Specified Index Values of Index Named Constant or Other Value Value Description For Index 1 String Title in quotes n a Defines the trend chart title For Index 2 Integer cbChfAdd 4 Adds the forecast in the selected cell to the list of chosen forecasts For Index 2 Integer cbChfClearList 5 Clears the list of chosen forecasts For Index 4 Boolean True or False n a True turns on vertical grid lines False turns them off For Index 5 Boolean True or False n a True turns on horizontal grid lines False turns them off For Index 6 Integer cbTypReverseCumulCert 1 Displays the reverse cumulative certainties view of the chart For Index 6 Integer cbTypCumulCert 3 Displays the cumulative certainties view of the chart For Index 6 Integer cbTypCertCenteredOnMedian 4 Displays the chart with certainties centered on the median 244 Crystal Ball Mac
218. hape parameters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter Use Value2to specify the number of the target parameter For Index 24 The name of a lockable Integer The index Specifies one of the following cbBftFitDistLockParamClear distribution from number of a distributions whose parameters are Table 55 see lockable cleared The following distributions from Description distribution Table 55 can be used as Value1 from parameters Table 55 see Description e Gamma distribution Location Shape parameters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter Use Value2 to specify the number of the target parameter For Index 30 cbBftOutputRows Integer 1 Indicates that output cells are in rows cbBftOutputOrientation equivalent of selecting Fill to the right in the user interface For Index 30 cbBftOutputColumns Integer 2 Indicates that output cells are in columns cbBftOutputOrientation equivalent of selecting Fill downward in the user interface CB BatchFitND 59 Table 12 CB BatchFitND Val
219. hartGroup MsgBox Group name for A3 amp GroupName GroupName CB GetAsmSensitivityChartGroup MsgBox Group name for A4 amp GroupName CB SetAsmSensitivityChartGroup Related Call A1 A2 A3 A4 A1 A2 A3 A4 Name Description CB GetAsmSensitivityChartGroup Returns the group name for an assumption in a sensitivity chart assumption group CB SetAssum This function changes attributes for an assumption without redefining the assumption using CB DefineAssumND Before you call this function the assumption must exist Table 181 CB SetAssum Returned Data Type Returned Value Returned Data Type Whether the function was successful Variant CB SetAssum 225 Table 182 CB SetAssum Parameters Parameter VBA Data Type Value Description AssumReference Variant In a macro Range B3 Points to the assumption cell with the data to change Index Integer See Table 183 Changes the assumption name and truncation points according to Value Value Variant See Table 184 Works with Index to specify an assumption name and truncation values Table 183 following describes the Index parameter Table 183 CB SetAssum Index Parameter Values Required Integer Named Constant Value Index Value Description cbAsmName 1 Changes the assumption name according to Value cbAsmLowCutOff 6 Changes the lower truncation point accordin
220. he Crystal Ball simulation and fits all distributions to a columnar data set in cells A1 through C500 including a header row The selected ranking method is Anderson Darling Results are output in a range on the current worksheet where D1 is the first cell in the upper left corner Resulting assumption correlations are displayed in a matrix Correlations are established for assumptions whose absolute correlation is equal to or greater than 0 2 Goodness of fit and assumption reports are created with specified names The assumption report includes full statistics The last line of code runs the Batch Fit tool CB ResetND Select all dis tributions CB BatchFitND cbBftSelectDistAll Set input range orientation data in columns CB BatchFitND cbBftInputOrientation cbBftInputColumns CB BatchFitND 61 Input range has headers CB BatchFitND cbBf tInputHeader True Select input range CB BatchFitND cbBf Select the CB BatchFitND cbBf tInputRange A1 C500 Anderson Darling ranking method tRankMethod cbFitAndersonDarling Select output location starting in cell D1 of a new worksheet CB BatchFitND cbBf Show correlation CB BatchFitND cbBf Do not format ou CB BatchFitND cbBf Output results to CB BatchFitND cbBf tOutputLocation cbBftNewWorksheet matrix between the data series tOutputCorrelationMatrix True False D1 tput tOutputFormat False Batch Fit Results tOutpu
221. he assumption is frozen and False if it is not frozen cbAsmlsSequential 11 Returns True if the assumption uses sequential sampling and False if it does not CB GetAssum 151 CB GetAssum Example 1 This example puts information for the first three Index constants for the assumption in cell B3 into cells F1 through F3 In a macro you can enter For i 1 To 3 CB CheckData Worksheets sheet3 Range F1 Offset i Value CB GetAssum Worksheets sheet1 Range B3 i Next i CB GetAssum Example 2 This example enters the name of the assumption in cell B3 into the cell that holds this formula In a worksheet cell you can enter CB GetAssumFN B3 1 CB GetAssum Related Calls Name Description CB DefineAssumND Defines or changes assumptions in selected cells without a dialog CB EnumAssum Enumerates assumption cells for open worksheets CB GetAssumPercent Returns percentile for an assumption cell CB GetDecVar Retrieves information for a specific decision variable cell CB GetFore Retrieves information for a specific forecast cell CB GetAssumPercent This function calculates the value of the specified assumption that corresponds to the specified percentile You can call this function from either a subroutine or a worksheet To call this function from a worksheet use the name CB GetAssumPercentEN Note In VBA code always call CB CheckData before calling this function to ensure the latest
222. he specified Crystal Ball call For example the following call to CB Simulation from a VBA module It is easy to translate code written in Visual Basic for Applications into Visual Basic code CB Simulation 1000 True can be replaced by the VB equivalent XL Run CB Simulation 1000 True How to Use the Crystal Ball Developer Kit 27 Note Crystal Ball subroutine and function names are case sensitive when called from outside Microsoft Excel Be sure to capitalize the CB module name that prefixes the call names In all other respects calling Crystal Ball from VB 4 0 is no different from calling it from VBA Creating a Microsoft Excel Add in To create a Microsoft Excel add in file oo N O OC bb C N e In the VBA editor select Tools then Properties Select the Protection tab Select Lock Project For Viewing Enter the appropriate password Click OK In Microsoft Excel select File then Save As In Save As Type select Excel Add In xla the last item Enter the name to use for the add in Click Save Using Developer Kit Macro Calls in User defined Macros Subtopics e User Defined Macro Interfaces e Priority Rules e Global Macros e Toolbar Macros You can run user defined Microsoft Excel VBA macros automatically during a simulation by naming them with predefined names 28 CBBeforeSimulation Runs immediately after the Start Simulation command or Single Step command CBBeforeTrial
223. heet must be active and the selected cell or range of cells must contain assumptions decision variables or forecasts Note Before calling this subroutine select a cell or cell range containing Crystal Ball data CB CopyData Example This example prompts you to select which data to copy either the assumption or forecast data It then copies only the selected data within the selected range Range selected in the following line contains an assumption and a forecast Range B5 C7 Select contains an assumption and a forecast CB CopyData CB CopyData Related Calls Name Description CB CopyDataND Copies selected assumptions decision variables or forecasts CB PasteData Pastes assumptions decision variables or forecasts into selected cells CB CopyDataND Subtopics e CB CopyDataND Example e CB CopyDataND Related Calls This subroutine stores a range definition for later use by CB PasteData which pastes all current Crystal Ball data of the selected type from the range stored by CB CopyDataND You can use CB CopyDataND with CB PasteData to quickly set up rows or columns of forecasts assumptions with similar distribution types or decision variables with similar bounds The worksheet must be active and the selected cell or range of cells must contain assumptions decision variables or forecasts This call has one parameter DataType described in Table 27 Table 27 CB CopyDataND DataType Parameter Inte
224. ialog CB ExtractDataND Extracts data from the current simulation and restored results optimization or time series forecast without a dialog CB ExtractDataND This function extracts Crystal Ball data from the current simulation For any preferences not explicitly set the default is the current setting in the Extract Data dialog Use CB CheckData before using this call You can extract more than one type of data For details see CB ExtractDataND Example 2 Note Before calling this function run a simulation OptQuest optimization or Predictor time series forecast Table 68 CB ExtractDataND Parameters Parameter Index VBA Data Type Integer Description Specifies which extract preference you are setting See Table 69 following CB ExtractData 133 Parameter VBA Data Type Description Value Optional Variant Specifies settings for the preference indicated by the Index See Table 69 for more information Value2 Optional Variant Specifies whether to extract the specified data type See CB ExtractDataND Example 2 The following are named constant and index values for the Index parameter Table 69 CB ExtractDataND Index Parameter Values Required Integer with Related Value Parameter Values Optional Variant Index Parameter Named Constant Value cbExtOK Index Parameter Index Value Value Parameter Values to Use n a Description Extracts the data Use this
225. iant See Table 190 Changes decision variable attributes specified with Index Table 189 following describes the Index parameter Table 189 CB SetDecVar Index Parameter Values Required Integer Named Constant Value Index Value Description cbDecName 1 Changes the decision variable name according to Value cbDecMin 2 Changes the minimum lower bound according to Value cbDecMax 3 Changes the maximum upper bound according to value 228 Crystal Ball Macro Calls Named Constant Value Index Value Description cbDecType 4 Changes the decision variable type according to Value cbDecStep 5 Changes the step size for discrete decision variables depending on Value cbDecFrozen 6 Freezes the selected decision variable depending on value cbDecCustomData 7 Supplies a list of possible values for coDecType Custom 4 Decimals can be used Table 190 following describes the Value parameter Table 190 CB SetDecVar Value Parameter Values Required Variant Used With Specified Values of Index For Index 1 coDecName String Value Decision variable name in quotes Description Specifies the new decision variable name For Index 2 cbDecMin Any number Sets the new minimum lower bound Double For Index 3 cbDecMax Any number Sets the new maximum upper bound Double For Index 4 cbDecType Integer cbDecVarTypeContinuous 0 cbDecVarTypeD
226. ided no macros exist at the workbook level If macros exist at the workbook level macros in that workbook at the worksheet level do not run e Ifa workbook has no Crystal Ball data cells no macros run against it e Macros in modules are not supported Global Macros If you want to run certain macros with any or all of the Crystal Ball models you need to make sure that the workbook containing those macros is open in Microsoft Excel Then you can use calls within each model to run those macros as required How to Use the Crystal Ball Developer Kit 31 Previous versions of Crystal Ball handled global macros differently Now you can run specific macros only for certain models and are no longer required to turn the macros on and off depending on the model that is being run Toolbar Macros If you want to use custom Microsoft Excel toolbar macros defined in a separate workbook while Crystal Ball is loaded be sure to save that workbook to the folder C Documents and Settings thename Application Data Microsoft Excel XLSTART A Note About Defaults and Write Protection Unless otherwise specified defaults are pulled from the user s preference files These defaults can be set through Crystal Ball s preference dialogs or preferences macro calls such as CB RunPrefsND in the Crystal Ball Developer Kit Caution Commands that change Crystal Ball data cells will not run if the cell or the entire worksheet is write protected For example
227. ies corresponding to the Predictor wizard Input Data panel This class enables you to control items such as input data range data orientation and headers PredSetup PredDataAttributes This class provides access to data attribute settings corresponding to the Predictor wizard Data Attributes panel This class enables you to control items such as seasonality data screening and outlier detection PredSetup PredMethods This class provides access to methods settings corresponding to the Predictor Methods panel This class enables you to control which time series and regression methods to use and to set method parameters 296 Using the Predictor Developer Kit PredSetup PredOptions This class provides access to Predictor options corresponding to the Predictor Options panel Use this class to specify options such as error measure and forecasting technique PredSetup PredSeries This class provides access to setup information for each series Use this class to manage individual input series information such as series name Microsoft Excel number format seasonality and cycle regression variable details statistics and access series data values An enumerator property of the PredSetup class Series enables you to access each series by index into the input data range Predictor Results Class Main classes for accessing Predictor results e PredResults main class interface for accessing Predictor results e PredResults PredResultsPrefe
228. igned to a group CB SetAsmSensitivityChartGroup Example The following example shows how to use this call and its parameters It also includes examples for CB GetAsmSensitivityChartGroup This example assumes that there are four assumptions defined At Al A2 A3 and A4 Set up groups for assumptions A1 and A3 CB SetAsmSensitivityChartGroup A1 Group 1 CB SetAsmSensitivityChartGroup A3 Group 1 Run simulation and create sensitivity chart CB Simulation 2000 224 Crystal Ball Macro Calls CB CreateChart cbChtSensitiv TestSensitiv Range B7 Select CB SensPrefsND cbSenTargetFore Verify the group names through Get calls Dim GroupName As String GroupName CB GetAsmSensitivityChartGroup MsgBox Group name for Al amp GroupName GroupName CB GetAsmSensitivityChartGroup MsgBox Group name for A2 amp GroupName GroupName CB GetAsmSensitivityChartGroup MsgBox Group name for A3 GroupName GroupName CB GetAsmSensitivityChartGroup MsgBox Group name for A4 amp GroupName Now remove groups CB SetAsmSensitivityChartGroup A1 CB SetAsmSensitivityChartGroup A3 Verify the group names through Get calls Dim GroupName As String GroupName CB GetAsmSensitivityChartGroup MsgBox Group name for Al amp GroupName GroupName CB GetAsmSensitivityChartGroup MsgBox Group name for A2 amp GroupName GroupName CB GetAsmSensitivityC
229. iles 1096 This is the default cbPctlcosatiles 4 Icosatiles 5 cbPctSet1 5 2 5 5 50 95 97 5 iles cbPctSet2 6 10 25 50 75 90 iles cbPctSet3 7 5 95 percentiles cbPctSet4 8 10 90 percentiles With Index set to coRptChooseFore you can specify which forecasts to include in the report see Table 35 Table 35 For Index cbRptChooseFore Value1 Values Optional Integer Named Constant Value Index Value Description cbChfAII 1 Includes all forecasts cbChfOpen 2 Includes open forecasts cbChfChosen 3 Includes chosen forecasts Run this option after adding forecasts cbChfAdd 4 Adds the forecast in the selected cell to the list of chosen forecasts cbChfClearList 5 Clears the list of chosen forecasts With Index set to cbRptChooseAssum you can specify which assumptions to include in the report see Table 36 Table 36 For Index cbRptChooseAssum Value1 Values Optional Integer Named Constant Value Index Value Description cbChaAll 1 Includes all assumptions cbChaChosen 2 Includes chosen assumptions Run this option after adding assumptions cbChaAdd 3 Adds the assumption in the selected cell to the chosen assumptions Use cbChaChosen after this option cbChaClearList 4 Clears the list of chosen assumptions cbChaOpen 5 Includes all open assumptions With Index set to cbRptChartType you can specify what type of chart the report uses see Table 37
230. imulation O no 1 yes cbForPrecisionPerc 12 Returns whether Crystal Ball uses the precision of a percentile value as a stopping criterion for the simulation O no 1 yes cbForPrecisionPercValue 13 Returns the percentile value used to check for the indicated precision cbForFilter 14 Returns whether Crystal Ball uses forecast filtering O no 1 yes cbForFilterlnside 15 Returns which forecast values Crystal Ball discards in filtering O the values outside the filtering range 1 the values inside the range cbForFilterFrom 16 Returns the lower bound of the filtering range cbForFilterTo 17 Returns the upper bound of the filtering range cbForFilterGlobal 18 Returns whether global filtering is set for the forecast True or not False cbForFrozen 19 Returns whether the forecast cell is frozen cbForLSL 20 Returns a lower specification limit LSL for the forecast cbForUSL 21 Returns an upper specification limit USL for the forecast cbForTarget 22 Returns a target value for the forecast Note The third constant for Index cbForWindowSize is obsolete and has been removed from Crystal Ball 7 x and 11 x CB GetFore Example This example puts information for Index constants 1 through 5 for the forecast in cell B3 into cells F1 through F5 In a macro you can enter For i 1 To 5 CB CheckData Worksheets sheet3 Range F1 Offset i Value _ CB GetFore Worksheets sheet1
231. imum value for the value axis For Index 8 Integer Any integer between O and Sets a third certainty band to display Use this with 100 inclusive Valuei and Value2 When Value1 is cbChfAdd the active cell must contain a forecast otherwise CB MacroResult returns cbErrNoForecastInCell Crystal Ball adds the selected cell to the list of forecasts to appear in the trend chart To display a specific set of forecasts in a certain order on the trend chart first clear the list of selected cells by calling this macro with Value1 set to cbChfClearList Then for each forecast use Range Select to highlight the desired forecast cell and call this macro with Value1 set to cbChfAdd You can set the percentage values of as many as seven certainty bands Set Index to cbTrdCertaintyBands and supply the percentage values in Va1ue1 through va1ue7 They will appear in the trend chart in the order that you define them so define them from smallest to largest or from largest to smallest CB TrendPrefsND 245 See the Oracle Crystal Ball User s Guide for more information on how to customize the trend chart CB TrendPrefsND Example This example runs a simulation of 1000 trials opens a trend chart and selects a forecast cell Then it clears the list of forecasts included in the trend chart adds the selected forecast to the trend chart sets the value axis to have a minimum of 0 and a maximum of 1000 and includes certainty bands of 0 25 50
232. ine on each plot if False does not display this information Table 169 following lists named constant and index values for the Value parameter Table 169 CB ScatterPrefsND Value Parameter Values Required Integer Used With Specified Index Values of Index Named Constant Value Value Description For Index2 3 Integer cbScatterAddSelectedVar 1 Adds selected variable to scatter chart For Index2 3 Integer cbScatterRemoveSelectedVar 2 Removes selected variable from scatter chart For Index2 3 Integer cbScatterRemoveAllVars 3 Removes all variables from scatter chart For Index 6 Integer cbScatterView 1 Plots each selected assumption or forecast against a target specified with Index 5 For Index 6 Integer cbMatrixView 2 Plots each selected assumption or forecast against every other selected variable For Index 9 Integer cbScatterPointSymbolRectangle 1 Draws rectangular scatter points For Index 9 Integer cbScatterPointSymbolCircle 2 Draws circular scatter points For Index 9 Integer cbScatterPointSymbolTriangle 3 Draws triangular scatter points CB ScatterPrefsND 213 Used With Specified Index Values of Index Named Constant Value Value Description For Index 9 Integer cbScatterPointSymbolDiamond 4 Draws diamond shaped scatter points For Index 9 Integer cbScatterPointSymbolMarble 5 Draws spherical scatter points default For Index 9 Integer cbScat
233. inimum Likeliest and Maximum parameters in cells E8 E9 and E10 CB SetFitRange Range D4 D104 For i 1to4 Range E3 Offset i Value CB Fit cbDfaTriangular i Next i For j 1 to 3 Range E7 Next j Off set j Value CB GetFitParm j CB GetFitParm Related Calls Name CB DefineAssum Description Defines an assumption in the selected cell using a dialog CB DefineAssumND Defines an assumption in the selected cell without using a dialog CB Fit Fits a specific probability distribution to a selected set of data range of cells 172 Crystal Ball Macro Calls Name Description CB GetLockFitParm Returns whether a distribution and optionally specific parameters have locked values for fitting purposes CB LockFitParm Sets parameter locking for distributions and optionally specific parameters CB SetFitRange Specifies the data range to be used as input for CB Fit CB GetFore This function retrieves information for a specific forecast cell Note For best results call CB CheckData before calling this function to ensure the latest data values are used Table 127 CB GetFore Returned Data Type Returned Value The specified forecast data Returned Data Type Variant Table 128 CB GetFore Parameters Parameter VBA Data Type ForeReference Variant Value Description In a macro Range B3 Points to the desired forecast cell I
234. ion run If not explicitly set the current settings from the Extract Data dialog are used cbExtDataPredictorType 16 Constant name or Specifies which type of Predictor data to extract number as described in the e 1 cbDatPredictorResults extracts results data next table cell e 2 cbDatPredictorMethods extracts methods data Note The constant is followed by a boolean True or False to indicate whether the constant is active or not cbExtPredictorResultsSheetName 17 A string value The name of the sheet where extracted Predictor results data representing a is placed The sheet name must follow appropriate sheet sheet name naming restrictions cbExtPredictorMethodsSheetName 18 A string value The name of the sheet where extracted Predictor methods representing a data is placed The sheet name must follow appropriate sheet sheet name naming restrictions cbExtPredictorResultsHistorical 19 True or False True includes historical data in extracted results False does not include historical data cbExtPredictorResultsFitted 20 True or False True includes fitted data in extracted results False does not include fitted data cbExtPredictorResultsForecast 21 True or False True includes forecasted data in extracted results False does not include forecasted data cbExtPredictorResultsConfidence 22 True or False True includes confidence interval data in extracted results False does not include confidence interval data CB ExtractDataND 135
235. is selected this call returns a cbErrNoSelection error for CB MacroResult Table 167 Parameters for CB ScatterPrefsND Parameter VBA Data Type Description Index Integer Works with Value to set scatter chart preferences For named constant and index values see Table 168 Value Integer Works with Index to set scatter chart preferences For named constant and index values see Table 169 Table 168 following lists named constant and index values for the Index parameter Table 168 CB ScatterPrefsND Index Parameter Values Required Integer Index Named Constant Value Value Description cbScatterTitle 1 Defines the scatter title according to the supplied string value title text cbScatterManageFore 2 Adds or removes the selected forecast to or from the chart according to Value cbScatterManageAssum 3 Adds or removes the selected assumption to or from the chart according to Value cbScatterSetTarget 5 If True sets the target value required for Scatter View if False clears it cbScatterViewType 6 Specifies the scatter view type according to Value cbScatterPlotSize T Specifies the scatter plot size with a value from 1 10 1 is the smallest plot and 10 is the largest cbScatterDrawPoints 8 If True displays scatter points if False does not display them cbScatterPointSymbol 9 Specifies the scatter point symbol according to Value cbScatterPointSize 10 Specifies the size of scatter points i
236. isND on page 102 CB DecisionTable on page 106 CB DecisionTableND on page 106 CB GetBatchFitOption on page 155 CB GetBootstrapOption on page 158 CB GetDataAnalysisOption on page 164 CB GetDecisionTableOption on page 166 CB GetScenarioAnalysisOption on page 182 CB GetTwoDSimulationOption on page 184 CB ScenarioAnalysis on page 215 CB ScenarioAnalysisND on page 216 CB TwoDSimulation on page 246 CB TwoDSimulationND on page 247 Special Calls The macro calls in this group can be used to Display the About box Enumerate assumptions decision variables and forecasts Determine if a worksheet or workbook contains Crystal Ball data Determine how many trials have run in a simulation Hide the Crystal Ball user interface in custom applications The subroutines and functions described in the following sections are included in this group 44 CB AboutBox on page 50 CB CalculateSpearman on page 67 CB CheckData on page 74 Crystal Ball Developer Kit Overview CB CheckDataND on page 75 CB EnumAssum on page 126 CB EnumCorrelation on page 128 CB EnumDecVar on page 130 CB EnumFore on page 131 CB GetVersion on page 187 CB GetWorksheetVersion on page 188 CB IsCBObject on page 189 CB Iterations on page 190 CB RuntimeMode on page 209 Special Calls 45 46 Crystal Ball Developer Kit Overview
237. iscrete 1 cbDecVarTypeBinary 2 cbDecVarTypeCategory 3 cbDecVarTypeCustom 4 For a detailed description of each of these cbDecType settings see CB DefineDecVarND on page 120 For cbDecVarlypeCustom a string of data must be supplied with Index cbDecCustomData 7 For Index 5 cbDecStep Double Any whole number smaller than the range and greater than 0 Sets the new step size for discrete variables For Index 6 cbDecFrozen Boolean True or False True freezes the current decision variable False unfreezes it if frozen For Index 7 cbDecCustomData String A list of at least two values separated by commas or a reference to a range of cells containing these values decimal values can be used The range must be one dimensional adjoining cells in one row or one column Supplies a list of data for coDecType cbDecVarTypeCustom 4 CB SetDecVar Example 1 This example changes the lower bound of the decision variable in cell B4 to 0 CB SetDecVar Range B4 2 0 CB SetDecVar Example 2 This example changes the type of the decision variable in cell B4 to Custom and passes the following values to it 10 20 30 40 CB SetDecVar 229 CB SetDecVar Range B4 cbDecType cbDecVarTypeCustom CB SetDecVar Range B4 cbDecCustomData 10 20 30 40 CB SetDecVar Related Calls Name Description CB DefineDecVar Defines or changes a decision variable in a selected
238. isplays 0 in the cell After a simulation it displays the standard deviation of the forecast in B7 In a worksheet cell you can enter CB GetForeStatFN B7 5 Note You must use the numeric value of the Index parameter in a worksheet cell The named constant will not work CB GetForeStat Related Calls Name Description CB EnumFore Enumerates forecast cells for open worksheets CB GetCertainty Returns the certainty level of achieving a forecast value at or smaller than a specific threshold CB GetFore Retrieves information for a specific forecast cell CB GetForeStat 179 Name CB GetForePercent Description Returns percentiles for forecast cells CB Simulation Runs a Crystal Ball simulation CB GetLockFitParm This function returns a different value depending on the parameter s passed to the call e If CB GetLockFitParm is called with only the distribution index it returns a boolean indicating whether locking is On or Off for that distribution e If CB GetLockFitParm is called with a distribution index and a parameter index it returns the value of the locked parameter if it is locked or cbParmUndefined if the parameter is not locked but can be locked or if the distribution and parameter combination is invalid for parameter locking Table 137 CB GetLocktFitParm Returned Data Type Returned Value Returned Data Type A boolean indicating whether locking is On True or Off Fals
239. l CB OpenChart CB OpenSelection CB OpenSensitiv CB OpenTrend CB RestoreResults CB RestoreResultsND CB RuntimeMode CB SaveResults CB SaveResultsND CB SelectChart Added in Crystal Ball 7 1 7 3 x 255 CB SensPrefs CB SensPrefsND CB SetCBWorkbookPriority CB SetFitRange CB TrendPrefs CB TrendPrefsND CB ScatterPrefs CB ScatterPrefsND CB SetCBAutoLoad CB SetExcel2007ForegroundMode CB Shutdown CB Startup CB WorksheetProtection Not Included in This Version The following calls available in Crystal Ball 2000 x 5 x or earlier versions are not currently available in this version of the Crystal Ball Developer Kit CB Auto_Open see CB Startup CB CloseCB see CB Shutdown CB CloseOverlay CB CopyCertainty CB CopyFore CB CopyOverlay CB CopyRangeMax CB CopyRangeMin CB ForeWindows CB FreezeAssum replaced by CB Freeze CB FreezeAssumND replaced by CB FreezeND CB Help CB OpenOverlay CB OverlayPrefs CB OverlayPrefsND CB RangePrefs CB RangePrefsND CB ResampleFore 256 Changes from Previous Versions CB RestoreRun replaced by CB RestoreResults CB RestoreRunND replaced by CB RestoreResultsND CB SaveRun replaced by CB SaveResults CB SaveRunND replaced by CB SaveResultsND CB SelectSome CB SetForeTrial CB SetView CB StatsPrefsND Regarding CB StatsPrefsND the following describes why it was omitted from this version of the Crystal Ball Developer Kit the constants cbStaBaseRange and cbRngDisplay ar
240. l 8 Fits to a Weibull distribution 140 Crystal Ball Macro a Named Constant Value Index Value Description cbDfaBeta 9 Fits to a beta distribution cbDfaGamma 12 Fits to a gamma distribution cbDfaLogistic 13 Fits to a logistic distribution cbDfaPareto 14 Fits to a Pareto distribution cbDfaExtremeValue 15 Fits to an extreme value distribution cbDfaNegBinomial 16 Fits to a negative binomial distribution cbDfaHypergeometric Success 17 Fits to a hypergeometric distribution with Success parameter cbDfaMinExtreme 18 Fits to a minimum extreme value distribution cbDfaMaxExtreme 19 Fits to a maximum extreme value distribution cbDfaStudentsT 20 Fits to a Student s t distribution cbDfaDiscreteUniform 22 Fits to a discrete uniform distribution cbDfaBetaPert 23 Fits to a betaPERT distribution cbDfaAutoSelectDist 50 Fits to whatever Crystal Ball chooses in the Distribution Gallery as the best type of distribution for fitting cbDfaAllContinuous 51 Fits the data to all continuous distributions in the Distribution Gallery those distributions in which every value in the distribution s range is possible cbDfaAllDiscrete 52 Fits the data to all discrete non continuous distributions in the Distribution Gallery except Yes No cbDfaAllDistributions 53 Fits to all continuous and discrete distributions except Yes No Note ThecbDfaExtremeValue constant is deprecated It is included for C
241. l Ball macro call worked correctly CB Iterations This function returns the number of trials performed thus far in the simulation You can call this function from either a macro or a worksheet Table 155 CB Iterations Returned Data Type Returned Value Returned Data Type The number of trials already run in a simulation Variant Note To call this function from a worksheet use the name CB IterationsFN CB Iterations Example 1 This example runs a simulation for 1000 trials 100 trials at a time After each 100 trials the current number of trials and the mean of the forecast in B7 at that point are put into cells on sheet 4 190 Crystal Ball Macro Calls Worksheets sheet1 Activate For i 1 To 10 CB Simulation 100 Worksheets sheet4 Range Al Offset i Value CB Iterations Worksheets sheet4 Range B1 Offset i Value _ CB GetForeStat Range B7 2 Next i CB Iterations Example 2 In a worksheet cell you can enter CB IterationsFN Example 2 enters the number of trials run so far into the cell CB Iterations Related Call Name Description CB Simulation Runs a simulation for a specified number of iterations CB LockFitParm This subroutine enables you to enter specific parameters for selected distributions when selecting distributions for fitting This can be helpful when locking to a specific value for location shape degrees of freedom or other pa
242. lay Chart 1 Trend Chart 1 Sensitivity Chart 1 CB OpenChart Example 2 This example runs a simulation calls CB CheckData because a CB Enum call follows and then opens the next overlay chart in the workbook CB Simulation 1000 CB CheckData CB OpenChart cbChtOverlay CB EnumChart cbChtOverlay CB OpenChart Related Calls Name Description CB CloseAllCharts Closes all open chart windows equivalent to Analyze then Close All CB CloseChart Closes the selected chart of the given type CB EnumChart Returns the unique name of the next chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB OpenFore This subroutine opens the forecast window for the selected cell The worksheet must be active a simulation run and a forecast cell selected for Crystal Ball to run this command CB OpenFore Example This example runs a simulation of 1000 trials activates the Model worksheet of the Futura with OptQuest xls workbook and selects cell C9 a forecast It then opens the forecast window associated with that cell CB Simulation 1000 Workbooks Futura with OptQuest xls Worksheets Model Activate Range C9 Select CB OpenFore CB OpenFore Related Calls Name Description CB CloseFore Closes the forecast window for the selected cell CB Simulation Runs a Crystal Ball simulation CB OpenFore 197 CB OpenSelection This subroutine is
243. le This code unloads Crystal Ball and returns TRUE in cell B2 when unloading is complete Range B2 Value CB Shutdown CB Shutdown Related Calls Name Description CB CBLoaded Indicates whether Crystal Ball is currently loaded within Microsoft Excel CB GetCBAutoLoad Returns the current Crystal Ball autoload setting that indicates whether Crystal Ball is set to open whenever Microsoft Excel opens CB SetCBAutoLoad Sets or cancels autoloading with Microsoft Excel determines whether Crystal Ball is set to open whenever Microsoft Excel opens CB Startup Loads Crystal Ball into Microsoft Excel if possible and indicates when Crystal Ball has been successfully opened CB SimResult This function returns the criterion that finally stopped the most recent simulation CB Shutdown 237 Note Before calling this function run a simulation or the function returns cbErrNotReady Table 201 CB SimResult Returned Data Type Returned Value Returned Data Type The stopping criterion used O for a calculation error 1 for maximum number of trials 2 for Crystal Ball precision Variant control or 3 for OptQuest confidence testing CB SimResult Example This example runs a simulation If Crystal Ball stops the simulation after the maximum number of trials 1000 in this example CB SimResult puts a 1 in cell B3 CB Simulation 1000 Range B3 CB SimResult CB SimResult Related Calls Name Descriptio
244. ling 286 errors 192 194 event handling 287 event macros 287 event signatures 289 events 288 AfterIterationEvent 290 AfterOptimizationEvent 290 AfterSimulationEvent 289 BeforelterationEvent 289 BeforeOptimizationEvent 289 BeforeSimulationEvent 289 EfficientFrontierEvent 290 example workbook 271 extracting CB data 133 extracting CB data 133 F filtering forecasts getting preferences 174 setting preferences 233 fitting distributions 139 170 171 180 191 231 forecast windows format preferences 144 145 A B C D E F G opening CB 197 preferences 71 72 forecasts closing CB 80 defining CB 123 enumerating CB 131 filtering 233 getting certainties 161 getting percentiles in CB 176 getting statistics for CB 177 retrieving CB information 173 selecting CB 221 setting CB attributes 232 trial data 175 formats forecast windows 144 formats forecast windows 145 freezing data cells 147 freezing data cells 147 function 23 functions in Crystal Ball spreadsheets 38 G global macros 31 291 grouping assumptions 149 224 H help developer kit 282 how this manual is organized 22 how to use the Developer Kit 26 l important classes OptQuest Developer Kit 279 installing the OptQuest Developer Kit 278 installing the Predictor Developer Kit 294 iterations 190 L listing charts 127 macro results 192 194 M N O P R S TU VW macros global 31 291 user defined 28 287
245. ll versions 187 custom applications 209 custom distributions 116 customizing scatter charts 211 212 sensitivity charts 221 222 trend charts 243 D data clearing CB 77 78 copying CB 82 83 extracting CB 133 forecasts 175 initializing CB 74 75 pasting CB 199 Data Analysis tool 101 102 164 data versions 188 Decision Table tool 106 decision variables defining 119 120 enumerating 130 retrieving information 168 selecting 220 setting attributes 228 DecisionTable tool 166 default values 32 defining assumptions 112 113 117 CB forecasts 123 custom assumptions creating custom assumptions 116 decision variables 119 120 definitions 23 deleting charts 125 Developer Kit how to use 26 welcome to 21 what s new 23 developer kit help 282 developer kit namespace Predictor 295 developer kit structure Predictor 294 developer kit OptQuest 277 278 developer kit Predictor 293 development environment 302 Index G L MN OP R S TU VW OptQuest 282 Predictor Developer Kit 298 development resources OptQuest 282 distribution fitting 139 170 171 180 191 distributions custom 116 fitting 231 E EfficientFrontierEvent 290 enumerating assumption cells 126 128 CB forecast cells 131 charts 127 correlations 128 decision variable cells 130 environment Predictor Developer Kit developmentt 298 environments OptQuest development 282 erasing CB data 77 78 error hand
246. llowing call unprotects sheet with current password CB WorksheetProtection passwd2 False following call clears the password CB WorksheetProtection False End Sub 252 Crystal Ball Macro Calls Changes from Previous Versions In This Chapter rro UP dec cde ca ned a a AD dec A E E E 253 PO m CVa BaN LETA duc SREE a ubacmntt 253 Added m Crystal Ball T l 353 acria ie Ie ted bee eed ee eed 254 Not Included in Tis VES ad ties a a as 256 Ghanees to EXISTS CAMS mer E 257 UDZ HILII er EERNINEE 270 Introduction This appendix lists differences between the 2000 5 5 5 version of the Crystal Ball Developer Kit and this version Most of these differences also apply to other 2000 x 5 x versions You can learn about new calls now available for use in future code and can use the lists of omitted and changed calls to troubleshoot conversion problems in existing code Added in Crystal Ball 11 1 x The following new calls were added to version 11 1 1 0 00 through 11 1 2 3 000 of the Crystal Ball Developer Kit They support new Crystal Ball tools parameter locking features in distribution fitting and correlation features Note Calls added in version 11 1 2 0 000 are marked with an asterisk Calls added in version 11 1 2 2 000 are marked with two asterisks Calls added in version 11 1 2 3 000 are marked with three asterisks CB BatchFit CB BatchFitND CB Bootstrap
247. ls CB RestoreResults Example This example automatically opens the Restore Results dialog to restore previously saved simulation results CB RestoreResults CB RestoreResults Related Calls Name Description CB RestoreResultsND Restores simulation results from a file without a dialog CB SaveResults Saves current simulation results data charts and reports using a dialog CB SaveResultsND Saves current simulation results data charts and reports without a dialog CB RestoreResultsND This subroutine automatically restores simulation results from the file specified by FileName See CB RestoreResults for more information about what is restored To run this subroutine you must have a saved cbr file or CB MacroResult returns cbErrRestoreResult You can restore any number of results files at one time but they must be restored one at a time You do not need to reset the current simulation before you run this subroutine You can restore results while a simulation is running completed or stopped If the file could not be read or is not a Crystal Ball results file CB MacroResult returns cbErrRestoreResult CB RestoreResultsND is similar to CB RestoreRunND available in Crystal Ball 2000 5 5 5 However CB RestoreRun and CB RestoreRunND restored an entire simulation saved with CB SaveRun or CB SaveRunND not just the results The existing simulation had to be reset before the saved simulation could be loaded and o
248. lt See Table 165 on page 206 Note The following Index constants used in Crystal Ball 2000 5 5 5 are now obsolete cbRunBurstMode 5 cbRunResetToOriginal 6 cbRunSensitivAnalysis 9 cbRunRetainUnsortedTrials 11 coRunMacroBeforeSimul 21 cbRunMacroBeforeRecalc 22 cbRunMacroAfterRecalc 23 coRunMacroAfterSimul 24 cbRunParadiseServer 30 cbRunBurstAmount 33 cbRunPrecisionWithin 45 cbRunPrecisionMean 41 used in versions before Crystal Ball 2000 5 5 5 is now obsolete In Crystal Ball 2000 5 5 5 values for coRunMode 29 were boolean in later versions of Crystal Ball the values are Integer Models from Crystal Ball 2000 5 5 5 that use this constant will not run successfully in later versions of Crystal Ball until the constant values are edited The following Value1 values Table 165 are used with the Index parameter to set Crystal Ball run preferences Table 165 CB RunPrefsND Valuei Parameter Values Required Variant Used With Specified Values of Index For Index 1 coRunMaxTrials Long Value Any positive whole number Description Sets the maximum number of trials For Index 2 cbRunStopOnError Boolean True or False True stops a simulation on calculation errors in forecast cells False does not For Index 4 coRunSameRandoms Boolean True or False True uses the same sequence of random numbers False does not 206 Crystal Ball Macro Calls
249. ludes the n a Constraints section in the report following an optimization run OptQuest constraints information False does not CB CreateRptND 95 Index Named Constant Value Value Description Value1 Optional Value2 Optional cbRptOptimizerDecVars 43 Includes the OptQuest Boolean True includes the n a Decision Variables section in OptQuest decision variables the report following an information False does not optimization run cbRptPredictorChart 45 Includes Predictor results Boolean True includes the Integer 1 to 200 charts for each series in the charts False does not defines the percent report following a Predictor run scale of the charts cbRptPredictorStatistics 46 Includes the Predictor Boolean True includes the n a Statistics section in the report Predictor statistics following a Predictor run information False does not cbRptPredictorAutocorrelations 47 Includes the Predictor Boolean True includes the n a Autocorrelations section in the Predictor autocorrelations report following a Predictor run information False does not cbRptPredictorForecast 48 Includes the Predictor Boolean True includes the n a Forecasts section in the report Predictor forecasts following a Predictor run information False does not cbRptPredictorConfidencelntervals 49 Includes the Predictor Boolean True includes the n a Confidence Intervals section in Predictor co
250. m assumptions 152 getting from CB forecasts 176 reversing 205 precision control getting preferences 173 setting preferences 233 Predictor Developer Kit 293 installation 294 namespace 295 structure 294 Predictor Developer Kit classes 295 Predictor setup classes 296 PredResults class 297 PredResults PredResultsPreferences class 297 PredResults PredResultsWindow class 297 PredResults PredSeriesResult class 297 PredSetup class 296 PredSetup PredDataAttributes class 296 PredSetup PredInputData class 296 PredSetup PredMethods class 296 PredSetup PredOptions class 297 PredSetup PredSeries class 297 preferences assumption 53 CB cells 68 69 CB run 204 forecast window 71 72 forecast windows format 144 145 getting run 181 R reports creating 91 92 resetting simulations 201 304 Index L MN OP R S TU VW resources OptQuest development 282 restoring simulation results 202 203 results macro 192 194 results saving 210 reversing percentiles 205 run preferences getting 181 setting 204 run results See simulations running simulations 238 running multiple simulations 240 Runtime example 271 Runtime mode 32 209 S sample OptQuest Developer Kit 284 saving results 210 saving simulation results 210 scatter charts copying 84 customizing 211 212 Scenario Analysis tool 182 215 216 selecting assumptions 219 CB forecasts 221 charts 219 decision variabl
251. m2 Parm3 and Parm4 for the new DistType constants CB DefineDecVar If a simulation was run earlier it must be reset before CB DefineDecVar is called CB DefineDecVarND If a simulation was run earlier it must be reset before CB DefineDecVarND is called 262 Changes from Previous Versions e Beginning in Crystal Ball 11 1 1 0 00 there are three new decision variable types Binary Category and Custom described in Table 58 e To support these new types a new optional parameter decVarType is added with the following new constants cbDecVarTypeContinuous 0 cbDecVarTypeDiscrete 1 cbDecVarTypeBinary 2 cbDecVarTypeCategory 3 and cbDecVarTypeCustom 4 e To support decVarType equal to cbDecVarTypeCustom a new optional parameter customData is added CB DefineForeND e Allparameters are now optional e Allparameter data types are now Variant e The optional WindowSize parameter is obsolete and has been removed e New optional parameters have been added to support the process capability features LSL USL and Target CB EnumAssum e Starting with Crystal Ball 1 7 2 this function now returns absolute cell references CB EnumDecVar e Starting with Crystal Ball 7 2 this function now returns absolute cell references CB EnumFore e Starting with Crystal Ball 7 2 this function now returns absolute cell references CB ExtractDataND e The Extract Data feature and dialogs have changed substantially since
252. macro by first testing for aTrial 0 In Extreme speed only two user defined macros are allowed CBBeforeSimulation and CBAfterSimulation The following sections provide details on user defined macros e User Defined Macro Interfaces on page 30 e Priority Rules on page 31 e Global Macros on page 31 e Toolbar Macros on page 32 How to Use the Crystal Ball Developer Kit 29 User Defined Macro Interfaces Subtopics CBBeforeSimulation CBAfterSimulation CBBeforeTrial CBAfterTrial CBAfterRecalc You must use special VBA interfaces for user defined macros Note If a macro returns anything other than zero 0 the simulation stops CBBeforeSimulation Public Function CBBeforeSimulation As Integer the code is here End Function CBAfterSimulation Public Function CBAfterSimulation _ alterations As Long _ aTrials As Long _ aMaxTrials As Long _ aProgress As Double _ aWasAborted As Boolean _ aWasStopOnError As Boolean _ aWasStoppedOnPrecision As Boolean _ aHasNewBestSolution As Boolean As Integer the code is here End Function In this interface parameters or arguments are defined as follows e alterations The number of the simulation in a multisimulation run usually 1 e aTrials Number of trials run e aMaxTrials Number of trials scheduled to run e aProgress Percent of trials completed e aWasAborted True if manually stopped e aWasStopOnError True if stopped on error e
253. mma False Report the locked parameter values Sheet1 Cells 6 12 Value cb GetLockFitParm cbDfaGamma 1 Sheet1 Cells 8 12 Value cb GetLockFitParm cbDfaGamma 3 Get result Result CB Fit cbDfaGamma cbFitAndersonDarling Write the parameters and results Sheet1 Cells 6 9 Value cb GetFitParm 1 Sheet1 Cells 7 9 Value cb GetFitParm 2 Sheet1 Cells 8 9 Value cb GetFitParm 3 Sheet1 Cells 9 9 Value Result 1 Now perform fit with locking First lock only the location parameter CB LockFitParm cbDfaGamma True 1 0 Shape is not locked we could have omitted this line CB LockFitParm cbDfaGamma True 3 cbParmUndefined Get fit result Result CB Fit cbDfaGamma cbFitAndersonDarling False Write the parameters and results Sheet1 Cells 6 10 Value cb GetFitParm 1 Sheetl Cells 7 10 Value cb GetFitParm 2 Sheet1 Cells 8 10 Value cb GetFitParm 3 9 10 Sheet1 Cells Value Result 1 Now lock the shape as well CB LockFitParm cbDfaGamma True 3 3 Get fit result Result CB Fit cbDfaGamma cbFitAndersonDarling False Write the parameters and results Sheet1 Cells 6 11 Value cb GetFitParm 1 Sheet1 Cells 7 11 Value cb GetFitParm 2 Sheet1 Cells 8 11 Value cb GetFitParm 3 95 X1 Sheet1 Cells Value Result Location Shape CB Fit 143 CB Fit Related Calls Name CB DefineAssum Description Defines an assumption in the selected cell using
254. mul before multiple simulations then call CB StopMultiSimul after the simulations are run 240 Crystal Ball Macro Calls Table 203 CB StartMultiSimul Parameters VBA Data Parameter Type Value Description Rescan Optional Boolean True or Indicates whether to rescan the workbook for each simulation call within a False multiple simulation The default is False which eliminates rescans for faster processing This optional parameter only works in Extreme Speed SaveAssumValues Boolean True or If set to True saves assumption values from multiple simulations for use in Optional False sensitivity analysis and other analyses The default is False MultiAutoDownshift Boolean True or With CB AutoDownshift set to True if Mul tiAutoDownshi ft is set to True Optional False Crystal Ball automatically downshifts to Normal speed when Extreme speed incompatibilities occur No dialog appears The default is False This optional parameter only works in Extreme Speed Note Ifa non decision variable cell referenced in a forecast formula a forecast precedent is changed between simulations there might be slight differences in results depending on whether Rescan is set to True or False If custom code is created where precedent values are changed manually between simulations these models need to call StartMultiSimul with Rescan set to True This change might also be true for some models running in Extreme Speed CB StartMultiSimul
255. mulation CB Simulation 1000 Define an assumption from best fit distribution for forecast in cell B1 Extract the assumption parameters as cell references with parameter name labels CB DefineAssumFromForeND Best Fit 118 Crystal Ball Macro Calls True True B1 True D1 cbAsmFromFstDistTypeBestFit Define a custom assumption with the values from forecast in Bl Retain the sequence of generated values to sample sequentially CB DefineAssumFromForeND B1 E1 cbAsmFromFstDistTypeCustom _ Sequential Custom Values SequentialCustom True Reset simulation to view new assumptions CB ResetND End Sub CB DefineAssumFromForeND Related Calls Name Description CB DefineAssum Defines or changes assumptions in selected cells using a dialog CB GetAssum Retrieves information for a specific assumption cell CB SetAssum Changes certain attributes for the assumption in a cell CB DefineDecVar This subroutine opens the Define Decision Variable dialog to create a new decision variable or change an existing decision variable in the selected cell The selected cell must be blank or a simple value cell You cannot define a decision variable in a cell with a formula a cell reference or text If a simulation runs before this subroutine is used the simulation must be reset before the decision variable is defined Note Before calling this subroutine reset the simulation and select a c
256. mulation This call runs the 2D Simulation tool and displays results without using a dialog This call returns a variant Note Before calling CB TwoDSimulationND reset the Crystal Ball simulation Table 210 CB TwoDSimulationND Parameters Parameter Required VBA Data Type Table Index Required Integer Table 211 Valuel Optional Integer Table 212 Value2 Optional Variant Table 213 Table 211 CB TwoDSimulationND Index Parameter Required Integer Named Constant Value Index cbTwoDChooseTarget 1 Description Sets the target forecast for the 2D simulation operation operates on the forecast in the currently selected cell use cell Select first to select the cell cbTwoDChooseAssum 2 Works with va1ue1 to choose assumptions for the uncertainty loop the variability loop or to clear the list operates on the assumption in the currently selected cell use cell Select first to select the Cell cbTwoDOuterSimTrials 3 Used with Va1ue1 to specify the number of trials in the outer uncertainty simulation loop cbTwoDInnerSimTrials 4 Used with va1ue1 to specify the number of trials in the inner variability simulation loop cbTwoDForeOption 5 Used with Valuez to set forecast chart window display options cbTwoDOutputOption 6 Used with va1ue1 to set output report options cbTwoDPercent 7 Used with Valuez to specify percentile settings cbTwoDMSDOption 8 Used with va
257. n CB RunPrefsND Sets what stopping criterion to use without a dialog CB Simulation Runs a Crystal Ball simulation CB Simulation This subroutine runs a Crystal Ball simulation on any open workbooks with Crystal Ball data for a specified number of trials Note The hide and minimize options are useful for increasing the speed of simulations Caution Note that Crystal Ball cannot run a simulation ifa cell with Crystal Ball data is located ina write protected worksheet If you run a simulation using CB Simulation without resetting Crystal Ball runs additional trials and adds the results to the existing results This means you can run more trials than the maximum set with the Run Preferences dialog or a Developer Kit macro call Table 202 CB Simulation Parameters VBA Data Parameter Type Value Description Iterations Long Any positive Specifies the number of trials to run If you already ran a simulation and integer did not reset it Crystal Ball runs this many more trials 238 Crystal Ball Macro Calls VBA Data Parameter Type Value Description Obsolete_ Variant null Used as a placeholder for the Asynchronous parameter removed Asynchronous Optional starting with Crystal Ball 11 1 1 0 00 HideForecasts Optional Variant True or False Sets whether to suppress forecast windows from opening normally during simulations True or to let them open as set in each forecast False Suppressing forecast
258. n For example a workbook with aPriority 10 will run before a workbook with CB SetCBAutoLoad 227 aPriority 20 CB SetCBWorkbookPriority runs only at the workbook level and not at the worksheet level For details see Running user defined macros at the end of Chapter 5 in the Oracle Crystal Ball User s Guide Table 186 CB SetCBWorkbookPriority Parameter Parameter VBA Data Type Value Description aPriority Long An integer of any size usually Specifies the running priority of user defined macros in a workbook positive The smaller the positive value the higher the priority CB SetCBWorkbookPriority Example This example assigns a priority of 10 to the workbook Book1 xls Application Workbooks Bookl xls Activate CB SetCBWorkbookPriority 10 CB SetDecVar This function changes certain attributes for a decision variable without redefining the decision variable using CB DefineDecVarND Table 187 CB SetDecVar Returned Data Type Returned Value Returned Data Type Whether the function was successful Variant Before you call this function the decision variable must exist and the simulation must be reset Table 188 CB SetDecVar Parameters Parameter VBA Data Type Value Description DecVarReference Variant In a macro Range B3 Points to the decision variable cell with the data to change Index Integer See Table 189 Works with Value to set decision variable attributes Value Var
259. n Shape parameters e Lognormal distribution Location parameter e Student stdistribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter CB GetBatchFitOption Example 1 This example returns the address of the selected input data range as a string CB GetBatchFitOption cbBftInputRange CB GetBatchFitOption Example 2 This example returns the locked value for parameter 3 Location for the lognormal distribution CB GetBatchFitOption cbBftFitDistLockParam cbDfaLogNormal 3 CB GetBatchFitOption Related Calls Name Description CB BatchFit Launches the Batch Fit tool CB BatchFitND Runs the Batch Fit tool without displaying dialogs CB GetBootstrapOption This function returns specified settings made by CB BootstrapND or the Bootstrap tool Table 101 CB GetBootstrapOption Returned Data Type Returned Value Returned Data Type The specified Bootstrap settings Variant 158 Crystal Ball Macro Calls Table 102 CB GetBootstrapOption Parameters Parameter Required VBA Data Type Table Index Required Integer Table 103 Index2 Optional Integer Table 104 Value Optional Variant Table 105 Table 103 CB GetBootstrapOption Index Parameter Required Integer Index Named Constant Value Value Description cbBtsGetTar
260. n decision or forecast data from ranges specified with CB CopyData and CB CopyDataND This subroutine together with CB CopyData and CB OpenTrend 199 CB CopyDataND helps you to quickly set up rows or columns of assumptions with similar distribution types or decision variables with similar bounds The worksheet must be active for Crystal Ball to run this command Assumption and decision variable data can be pasted into simple value cells or blank cells Forecasts may be pasted only into value or formula cells If assumptions or decision variables are pasted into a range that is totally blank any underlying Microsoft Excel values are pasted along with the Crystal Ball data If the range selected for pasting contains more value or formula cells than are selected for copying the cells will repeat For example if the CopyData range includes two assumptions and the PasteData range includes three value cells the first and second assumptions are pasted and then the first assumption is repeated Note Before calling this subroutine copy Crystal Ball data using CB CopyData or CB CopyDataND CB PasteData Example 1 This example copies the Crystal Ball data from cell C1 and pastes it into cell D1 Range C1 Select CB CopyData Range D1 Select CB PasteData CB PasteData Example 2 This example copies the assumption data from cells B5 B6 and B7 and then pastes it into the corresponding cells D1 D2 and D3 provided those cells
261. n 1000 Range A10 Value CB GetForeData Range B1 100 CB GetForeData 175 CB GetForeData Example 2 This example pastes the value of the 100th trial of the forecast in B1 into the cell where the function is entered In a worksheet you can enter CB Get ForeDataFN B1 100 CB GetForePercent This function calculates the value of the specified forecast that corresponds to the specified percentile You can call this function from either a macro or a worksheet Note To call this function from a worksheet use the name CB GetForePercentEN Table 132 CB GetForePercent Returned Data Type Returned Value Returned Data Type Forecast value that corresponds to the specified percentile Variant You must run a simulation before you call this function or it returns 0 Note Reversing the percentiles using the cbRunReversePercentile constant does not affect the output of this function For more information see CB RunPrefsND on page 204 Table 133 CB GetForePercent Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 Points to the forecast cell for which you want the percentile value In a worksheet B3 Percent Double A number between 0 and 100 Specifies the percentile for which you want the forecast value CB GetForePercent Example 1 This example runs a simulation of 1000 trials and then puts the values for every fifth percentile into
262. n a Uniform minimum maximum n a n a Exponential rate n a n a n a Weibull location scale shape n a CB GetFitParm 171 Last Distribution Index 1 returns Index 2 returns Index 3 returns Index 4 returns Beta alpha beta maximum minimum Gamma location scale shape n a Logistic mean scale n a n a Pareto location shape n a n a Extreme value likeliest scale max True or min False n a Minimum extreme value likeliest scale n a n a Maximum extreme value likeliest scale n a n a Student s t midpoint scale degrees of freedom n a BetaPERT minimum likeliest maximum n a Note The parameters for beta have changed since Crystal Ball 2000 x 5 x There are now four parameters Extreme value is deprecated It is included for Crystal Ball 2000 5 5 5 compatibility and is replaced by cbb aMinExtreme and cbDfaMaxExt reme in later versions of Crystal Ball Beginning with version 11 1 1 0 00 the lognormal distribution has three parameters instead of two If this call is used in a model that was created in an earlier version of Crystal Ball the third parameter has a value of 0 CB GetFitParm Example This example selects a range of data in column D and then calls CB Fit to fit a triangular distribution to the range of data printing the results of each possible test to the worksheet next to the original data in cells E4 to E7 After the fit it uses CB GetFitParm to put the M
263. n decision variable cells to be the maximum of the defined range The Value parameter values listed in the following table work with the Index2 parameter values to set cell preferences For Index2 values see Table 21 Table 22 CB CellPrefsND Value Parameter Values Variant Required Used With Specified Values of Index2 Named Constant or Boolean Value Index Value Description For zndex2 1 cbCelPattern Integer n a O through 17 O specifies no pattern 1 through 17 specify available patterns For Index2 2 cbCelColor Integer n a 0 to 15 O specifies no color 1 15 specify available colors For Index2 3 cbCelNote Boolean True or False n a True turns on notes False turns off notes For Index2 4 cbCelDistMean True or False n a For assumption cells True changes the cell value to the Boolean mean False leaves the existing values in the cells For Index2 4 True or False n a For decision variable cells True changes the cell value to cbCelRangeMidpoint Boolean the midpoint False leaves the existing values in the cells For Index2 5 cbCelDistMedian True or False n a For assumption cells True changes the cell value to the Boolean median False leaves the existing values in the cells For Index2 6 cbCelRangeMin True or False n a For decision variable cells True changes the cell value to Boolean the range minimum False leaves the existing values in the cells For Index2 7
264. n is searched first and then the range above If there are non blank cells both to the left and top unexpected behavior can result Seethe Oracle Crystal Ball User s Guide for more information on specifying correlations between assumptions CB CorrelateMatrixND Example 1 This example creates a lower triangular 3x3 correlation matrix in range B2 D4 with assumptions adjacent to the matrix range A2 A4 and then formats the matrix CB CorrelateMatrixND Range B2 D4 True cbCorrMatrixdAdjAsms FormatMatrix True The following example adds assumption names to the previous example CB CorrelateMatrixND Range B2 D4 True cbCorrMatrixdAdjAsms FormatMatrix True AddNames True CB CorrelateMatrixND 89 The following example clears formatting from the previous example CB CorrelateMatrixND Range B2 D4 True cbCorrMatrixdAdjAsms FormatMatrix False AddNames True CB CorrelateMatrixND Example 2 This example updates the matrix defined in CB CorrelateND Example 1 on page 87 to a 4x4 matrix in range B2 E5 CB CorrelateMatrixND Range B2 E5 True cbCorrMatrixdAdjAsms CB CorrelateMatrixND Example 3 This example creates an upper triangular 3x3 correlation matrix in range B2 D4 with assumptions in cells B6 C7 and D8 CB CorrelateMatrixND Range B2 D4 False cbCorrMatrixAsmPicker Range B6 C7 D8 CB CorrelateMatrixND Example 4 This example removes a correlation matrix in range B2 D4 that is correlated to
265. n nta banasa d usata uacua A a Gard ud RR COAUTOR 204 Hi gr M dia 204 o A sasantun a jM E dot aaa 209 CB SaveResults ccoooocooococccccnnononnnonos nanu PO iaa 210 CB SoveResulteND cid ee 210 EB SCOPO odo d ADIRI FORDERN LU RR RUNE AURA D N T UR tae LE CCA O mem TD rr 212 CB ScenarioAnalySis cccccecseeeeeeeeeeeueees A oa E CB ScenarioAnalysisND Rn 216 Mae D ntc m 219 DB OBI Ho A a Ol CB Sel ep DOG ausus neci e RA OR A TE UIROS bred re RR REI ee Loc Dui md mE EU Ig M S a A END sikelele nee ER E FR C eee CB SetAsmSensitivityChartGroup Sieben diede old eR d edad qc UA 224 CE SOURS eT E E E 225 49 E CECU irs dnb rd EEA 227 CB Sel BWOTEDOOHPHOND oir ri ac ii caia 227 CB OID OCU a E 228 UB AECE POTS A MOE NE a a en aa eto 230 inc pop NT T CT 231 UB Set BST i od iiec arenes kind rag ad ebbe es Haber A 291 UB SOG e ETET 232 COORD t 235 Ime Io PPP A 231 CB I Mem 237 E SAO aca aang oa a 238 EM Rm TIT E 240 Bomorad ru Me ES 240 CB ert S A Le beef ocio Leti On Curt Cent bosch beo qol dd Ve DD Dun PR ined Ferd que 242 A dade didi is adu tad VR U Ee d ad Rd dU 242 INI DII ETUDES LO LET 243 CB WENO AA 243 A ITE Uic TP e TTC 246 EBORE os
266. n of 500 trials selects cell B7 and then opens the Chart Preferences dialog CB Simulation 500 Range B7 Select CB ChartPrefs CB ChartPrefs Related Calls Name Description CB ChartPrefsND Sets chart preferences for the forecast or assumption corresponding to the selected cell without displaying the Chart Preferences dialog CB Simulation Runs a Crystal Ball simulation CB ChartPrefs 71 CB ChartPrefsND Subtopics e CB ChartPrefsND Example e CB ChartPrefsND Related Calls This subroutine sets chart preferences for the forecast or assumption corresponding to the selected cell without displaying the Chart Preferences dialog The default for any preference is the previous setting in the Chart Preferences dialog Note You must select a forecast or assumption cell before calling this subroutine to change the chart preferences for a single forecast or assumption If you call this subroutine to change a single forecast or assumption chart A11 is False when no forecast or assumption cell is selected CB MacroResultDetail NewValue returns error code 5102 Table 23 CB ChartPrefsND Parameters Parameter VBA Data Type Description Index Integer Sets basic forecast and assumption chart preferences according to the value parameter settings For constant and index values see Table 24 Value Variant Works with the Index parameter to set forecast and assumption chart preferences For available value settings
267. n pixels 1 30 212 Crystal Ball Macro Calls Index Named Constant Value Value Description cbScatterPointColor 11 Specifies the scatter point color 0 15 as defined in the Chart Preferences dialog Chart Type tab O Auto cbScatterDrawLines 12 If True displays a fit line on the scatter chart if False lines do not appear cbScatterLineWidth 13 Specifies the scatter line width in pixels 1 10 cbScatterLineType 14 Specifies the type of scatter line according to Value cbScatterLineColor 15 Specifies the scatter line color 0 15 as defined in the Chart Preferences dialog Chart Type tab O Auto cbScatterCriteriaLimit 16 Specifies the scatter chart criteria to use according to Value cbScatterCriteriaLimitNumber 17 Defines the number of trials to appear taken into account only if cbScatterCriteriaLimit LimitTrialNumber Value cbScatterCriteriaLimitPercentage 18 Defines the percentage of trials to show taken into account only if cbScatterCriteriaLimit LimitTrialPercentage Value with a possible range of 1 100 cbScatterDrawCorrelationCoefficient 19 If True displays a correlation coefficient for each plot if False does not display the correlation cbScatterShowFilteredOutValues 20 If True displays filtered out values if False does not display filtered out values boolean cbScatterShowLinearRegressionCoefficients 21 If True displays the slope and Y intercept for the linear regression l
268. n the Language Filter menu and the Visual Basic tab is selected in the Syntax tab group OptDevKitRuntimeSample xls This sample file contains code for two different optimization sequences both based on the Portfolio Allocation example models This file is located in the Examples folder beneath the main Crystal Ball installation folder To use it open OptDevKitRuntimeSample xls in Crystal Ball Choose to enable the macros Then open your development environment for example the Microsoft Excel Visual Basic Editor In the project tree select the class module PortfolioOptimizeClass Commented sample code appears in the code window You can run the code by clicking buttons on the Model worksheet Then you can examine the code and the comments to see how the samples were constructed For more information about this sample see Coding an Optimization on page 285 following 284 Using the OptQuest Developer Kit Coding an Optimization An optimization has three phases building the model setting up the optimization and then running it The sample code in OptDevKitRuntimeSample xls illustrates these steps with two sample optimizations The first is based on Portfolio Analysis xls in the Crystal Ball Examples folder The second adds Efficient Frontier analysis If you haven t already you might find it helpful to complete Tutorial 2 in the Oracle Crystal Ball Decision Optimizer OptQuest User s Guide This tutorial explains how to complete the Port
269. nce settings You can call this function from either a macro or a worksheet See Table 163 for a list of valid parameters CB GetRunPrefs 181 Table 139 CB GetRunPrefs Returned Data Type Returned Value Returned Data Type The specified run preference setting Variant Note To call this function from a worksheet use the name CB GetRunPrefsEN Parameters are the ones listed in Table 163 and return the values listed there CB GetRunPrefs Example 1 This example puts the current settings for the first four run preferences into cells M10 through M13 In a macro you can enter the line For i 1 To 4 Range M9 Next i Offset i 0 Value CB GetRunPrefs i CB GetRunPrefs Example 2 This example puts the current sample size into the cell In a worksheet cell you can enter CB GetRunPrefsFN 8 CB GetRunPrefs Related Calls Name Description CB RunPrefs Changes simulation settings using a dialog CB RunPrefsND Changes simulation settings without a dialog CB GetScenarioAnalysisOption This function returns specified settings made by CB ScenarioAnalysisND or the Scenario Analysis tool Table 140 CB GetScenarioAnalysisOption Returned Data Type Returned Value Returned Data Type The specified Scenario Analysis settings Variant 182 Crystal Ball Macro Calls Table 141 CB GetScenarioAnalysisOption Parameters Parameter Required VBA Data Type Table Index Required Integ
270. nd which tells you it has reached the maximum number of trials and requires you to reset the simulation CB Reset Example This example prompts you to confirm and then clears any simulation data and closes all forecast windows and charts CB Reset CB Reset Related Calls Name Description CB ResetND Resets a simulation without confirmation CB Simulation Runs a simulation for specified number of iterations CB ResetND This subroutine resets the current simulation without prompting you to confirm the reset It automatically closes all forecast windows the trend chart the overlay chart and the sensitivity chart then it clears results from the previous simulation CB Reset 201 This is very useful to use before calls to subroutines and functions that require that a simulation be reset such as CB Freeze You can also call this subroutine to make sure that simulations start at Trial 1 For users to confirm the reset use CB Reset because it includes a prompt before it runs You do not have to run a simulation before you call this subroutine However it is convenient to run to ensure that no prior simulation results are around Note Ifyou run a simulation using the CB Simulation subroutine without resetting Crystal Ballruns additional trials and adds the results to the existing results This is different from the user interface command which tells you it has reached the maximum number of trials and requires you to
271. ndex Integer See Table 129 Retrieves information for a specific forecast cell using the values in Table 129 The following table Table 129 shows values available for the Index parameter Table 129 CB GetFore Index Parameter Values Required Integer Index Named Constant Value Value Description cbForName 1 Returns the forecast name cbForUnits 2 Returns the forecast units cbForAutoOpen 4 Returns whether Crystal Ball displays the forecast window automatically O no 1 yes cbForOpenWhen 5 Returns when Crystal Ball displays the forecast window O when running cbOpnWhenRunning 1 when stopped cbOpnWhenStopped cbForPrecision 6 Returns whether Crystal Ball uses precision control O no 1 yes cbForPrecisionAbsolute T Returns what kind of terms Crystal Ball uses to define the confidence interval around the stopping criterion O relative 1 absolute cbForPrecisionAbsoluteValue 8 Returns the size of the confidence interval in absolute forecast units CB GetFore 173 Index Named Constant Value Value Description cbForPrecisionRelative Value 9 Returns the size of the confidence interval in relative percentage terms cbForPrecisionMean 10 Returns whether Crystal Ball uses the precision of the mean as a simulation stopping criterion 0 no 1 yes cbForPrecisionStdDev 11 Returns whether Crystal Ball uses the precision of the standard deviation as a stopping criterion for the s
272. nfidence the report following a Predictor intervals information False run does not cbRptPredictorMethods 50 Indicates which Predictor Integer See Table 43 n a Methods to include in the following report cbRptincludeUnspecifiedCorrs 51 Supports the Include Boolean True includes n a unspecified correlations calculated values as well as report preference those entered directly False includes only directly entered correlations Note The following constants have been removed since Crystal Ball 2000 5 5 5 cbRptForeFrequencies Index 8 obsolete coRptDecVar Index 15 included in CB 7 1 and later for compatibility users should migrate to using coRptChooseDecVar instead cbRptScatterChart 38 and similar constants such as coRptOverlayChart 14 include all open charts of the selected type as stated in their descriptions These constants override any previous settings made with Choose commands such as cbRptChooseScatter 31 The coRptOptimizer constants 39 43 were added in Crystal Ball 11 1 1 0 00 With Index set to cbRptForePercentiles you can specify which percentile ranges to include in the report see Table 34 96 Crystal Ball Macro Calls Table 34 For Index cbRptForePercentiles Value2 Values Optional Integer Named Constant Value Index Value Percentile Ranges cbPctQuartiles 1 Quartiles 2596 cbPctQuintiles 2 Quintiles 2096 cbPctDeciles 3 Dec
273. ng custom reports or automating post optimization analysis e Setting up specialized optimization environments The OptQuest Developer Kit provides a link between OptQuest and your program It consists of a number of object oriented development classes that control many aspects of OptQuest Each copy of Crystal Ball Decision Optimizer comes enabled to use the OptQuest Developer Kit so that programs you develop today can be run by other users with appropriate licenses The OptQuest Developer Kit provides a framework of classes that you can use with OptQuest to perform optimizations It isa COM Component Object Model object which allows the use of older languages that support ActiveX objects such as Visual Basic 6 0 VB6 C VBA and others Who Should Use This Kit The OptQuest Developer Kit is appropriate for advanced users who want to automate repetitive spreadsheet optimization processes This book assumes that readers are familiar with a COM compatible development platform and Crystal Ball with OptQuest About the OptQuest Developer Kit 277 What This Kit Includes In addition to this book the OptQuest Developer Kit includes the following files available in the specified folders under the Crystal Ball installation folder by default C Program Files Oracle Crystal Ball e CBCOMDevkKit tlb in the Bin folder accessible directly and through CBDevKit xla in the Crystal Ball installation folder e OptDevKitRuntimeSample xls
274. nge 170 Crystal Ball Macro Calls CB GetFitFilter Example Considering CB Fit Example 3 on page 142 the statement CB GetFitFilter cbFitFilterFrom called for that code would return 10 CB GetFitFilter Related Calls Name CB Fit Fits a specific probability distribution to a selected set of data range of cells CB SetFitFilter Specifies a data range to include in or exclude from the data range to use as input for CB Fit CB SetFitRange Specifies the data range to use as input for CB Fit CB GetFitParm This function returns the value of the specified distribution parameter for the last CB Fit Table 125 CB GetFitParm Returned Data Type Returned Value Returned Data Type The distribution parameter for the last CB Fit as specified by Index Variant Note Before calling this function call CB Fit or the function returns 0 CB GetFitParm has one parameter Index an integer The Index parameter specifies which distribution parameter value to return Its has only four values 1 2 3 and 4 The following table shows which values are returned for each distribution Table 126 CB GetFitParm Index Parameter Values Required Integer Last Distribution Index 1 returns Index 2 returns Index 3 returns Index 4 returns Normal mean standard deviation n a n a Triangular minimum likeliest maximum n a Lognormal mean standard deviation location
275. ngle cell outside of the Sets a single assumption cell as the second cell to correlate Optional Range specified range on the same or with the first specified cell in a selected range The second another worksheet cell specified with SecondAsm should not be part of the selected range and can be on another worksheet in the same workbook To specify two assumption cells to correlate either e Select a rectangular cell range so that the two assumptions define opposite corners or endpoints of a column or row or e Select a single assumption cell and use the optional SecondAsm parameter to define a second assumption cell on the same worksheet or another worksheet on the same workbook If the cells to correlate are in the lower left the lowest column and the highest row and upper right highest column and lowest row corners of the selected range activate one of the cells before calling this subroutine If the two assumption cells are in the same column or row the selected cell range is one cell wide or tall If the cells are adjacent the selected region has exactly two cells in it Unless you are using the SecondAsm parameter both the selected cell and the opposite corner of the selected range must contain assumption cells If the selected region is just one cell use SecondAsm to define a second cell because you cannot correlate a cell with itself If there is an error in specifying the cells to be correlated CB CorrelateND re
276. nly one simulation could be restored at a time Table 162 CB RestoreResultsND Parameters Parameter VBA Data Type Value Description FileName String A path surrounded by quotes such as C temp sheet2 Points to the saved results file to restore cbr See the Oracle Crystal Ball User s Guide for more information on saving simulation results CB RestoreResultsND Example This example automatically restores the previously saved simulation file saveme cbr CB RestoreResultsND C temp saveme cbr CB RestoreResultsND 203 CB RestoreResultsND Related Calls Name CB RestoreResults Description Restores simulation results from a file using a dialog CB SaveResults Saves current simulation results using a dialog CB SaveResultsND Saves current simulation results without a dialog CB RunPrefs This subroutine opens the Run Preferences dialog so you can change simulation settings CB RunPrefs Example This example opens the Run Preferences dialog CB RunPrefs CB RunPrefs Related Calls Name CB GetRunPrefs Description Returns a run preference setting CB RunPrefsND Changes run preferences settings without a dialog CB RunPrefsND This subroutine sets preferences corresponding to the Run Preferences dialog Any run preferences not explicitly defined default to the current setting in the Run Preferences dialog See the Oracle Crystal Ball User s Guide fo
277. nother worksheet in the same workbook CB CorrelateMatrixND Two new optional parameters FormatMatrix and AddNames are added in 11 1 2 3 500 CB CreateRpt e Can now be called while a simulation is running CB CreateRptND e Can now be called while a simulation is running e Is substantially changed to support the revised Create Report command in Crystal Ball 7 x and later including 11 x o The Index constant cbRptForeFrequencies 8 is removed obsolete o Index constant cbRptDecVar 15 is deprecated cbRptChooseDecVar 18 should be used instead o Index constant RptExistingSheet 16 is changed so that True creates the report on a new sheet instead of the existing sheet of the current workbook while False creates the report in a new workbook o NewIndexconstants with index values of 17 26 28 30 and 32 37 are added as described in Table 33 o Additional constants for parameters Valuel and Value2 are added to support the new Index constants They are listed in Table 38 through Table 42 o Unlike in pre 7 0 versions the following statement needs to be added at the beginning of the Create Report code to create a custom report CB CreateRptND cbRptDefinedType cbRptCustom Otherwise the type of report currently selected in the Create Report dialog by default the Full report is created e For Index constants supported in Crystal Ball 2000 5 5 5 the following changes appear o cbRptForePercentiles two new
278. nsPrefsND cbSenDisplayOnlyHighest True 4 CB SensPrefsND cbSenDisplayGreaterThan True 0 1 CB OpenSensitiv CB SensPrefsND 223 CB SensPrefsND Related Call Name Description CB SensPrefs Opens the Sensitivity Preferences dialog for the selected sensitivity chart CB SetAsmSensitivityChartGroup This subroutine is used to assign an assumption to a sensitivity chart group or remove an assumption from a group Each assumption can be included in only one group You can use a blank string in this call to clear the group name assigned to an assumption and remove the assumption from the group Before you call this subroutine the assumption must exist Table 179 CB SetAsmSensitivityChartGroup Returned Data Type Returned Value Returned Data Type Whether the group assignment was successful Variant This subroutine has two required parameters the section called CB CorrelateMatrixND Example 4 Table 180 CB SetAsmSensitivityChartGroup Parameters Required Parameter VBA Value Description Data Type AssumReference Variant In a macro Range B3 Specifies the cell of the assumption to be assigned to or removed from a sensitivity group GroupName String The name of an assumption group in Specifies the name of a sensitivity chart assumption group to a sensitivity chart or an empty which the assumption in AssumReference will be string assigned an empty string indicates the assumption is not ass
279. nt and index cbChtTrend 4 values see the Value column CB CloseAllCharts VBA Data Parameter Type Value Description Chart ID Optional String Chart ID The chart ID returned by CB EnumChart Table 62 entered directly or using CB EnumChart CB CloseChart Example This example runs a simulation calls CB CheckData because a CB Enum call follows and then closes the next overlay chart in the workbook CB Simulation 1000 CB CheckData CB CloseChart cbChtOverlay CB EnumChart cbChtOverlay CB CloseChart Related Calls Name Description CB CloseAllCharts Closes all open chart windows equivalent to Analyze then Close All CB EnumChart Returns the chart ID of the next chart of the specified type CB OpenChart Opens the selected chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB CloseFore Subtopics e CB CloseFore Example e CB CloseFore Related Calls This subroutine closes the forecast window for the selected cell The worksheet must be active and a forecast cell selected for Crystal Ball to run this command Note Before calling this subroutine activate a worksheet and select one forecast cell CB CloseFore Example This example activates the Model worksheet of the Futura With OptQuest xls workbook and selects cell C9 a forecast Then it closes the forecast window associated with that cell Workbooks Futura with OptQue
280. nt and not restored results Table 174 CB SelectChart Parameters and Values VBA Data Parameter Type Value Description SimChartType Integer cbChtOverlay 1 cbChtScatter 2 cbChtSensitiv 3 cbChtTrend 4 Specifies the type of chart you are selecting overlay scatter sensitivity or trend charts according to the named constant and index values listed in the Value column CB SelectAssum 219 VBA Data Parameter Type Value Description Chart ID String The string ChartlD returned from CB Indicates the chart to select EnumChart or CB CreateChart CB SelectChart Example This example runs a simulation and selects the next overlay chart found in the workbook Because CB EnumChart is used here call CB CheckData CB Simulation 1000 CB CheckData CB SelectChart cbChtOverlay CB EnumChart cbChtOverlay CB SelectChart Related Calls Name Description CB CheckData Checks decision variables for validity initializes variables CB CreateChart Creates a new chart of the specified type with the optional name if specified CB EnumChart Returns the unique name of the next chart of the specified type CB SelectDecVar This subroutine selects all decision variables in the current worksheet The desired worksheet must be active for Crystal Ball to run this command Note Before calling this subroutine activate the worksheet where you want to select Crystal Ball data
281. nt spreadsheet CB SelectChart on page 219 Selects the chart with the specified chart ID CB SelectDecVar on page 220 Selects all decision variables in the current spreadsheet CB SelectFore on page 221 Selects all forecasts in the current spreadsheet CB SensPrefs on page 221 Opens the Sensitivity Preferences dialog for the selected sensitivity chart CB SensPrefsND on page 222 Sets preferences for the specified sensitivity chart CB SetAsmSensitivityChartGroup on page 224 Assigns an assumption to a sensitivity chart group or removes an assumption from a group CB SetAssum on page 225 Changes certain attributes for the assumption in a cell CB SetCBAutoLoad on page 227 Sets or cancels autoloading with Microsoft Excel determines whether Crystal Ball is set to open whenever Microsoft Excel opens CB SetCBWorkbookPriority on page 227 Sets the running order for macro applications when multiple workbooks are open CB SetDecVar on page 228 Changes certain attributes for a decision variable CB SetExcel2007ForegroundMode on page 230 Sets the Run Preferences foreground mode setting for Microsoft Excel 2007 or later in Normal speed CB SetFitFilter on page 231 Specifies a data range to include in or exclude from the data range to use as input for CB Fit CB SetFitRange on page 231 Specifies the data rang
282. ntain a simple value an expression or a cell reference otherwise CB MacroResult returns cbErrNoForecastInCell Note Before calling this subroutine select a cell CB DefineFore 123 Table 59 CB DefineForeND Parameters VBA Data Parameter Type Value Description FName Optional Variant Title surrounded by quotes Specifies how Crystal Ball identifies the forecast If you do not 0 specify a name Crystal Ball uses the first of either the cell s range name text from the cell in the column immediately preceding it to the left text from the cell in the row immediately preceding it above or the cell s coordinates Units Optional Variant Words surrounded by Specifies the units label of the forecast chart quotes DisplayAuto Optional Variant True or False True sets the forecast window to open automatically according to the DisplaywWhileRunning setting False requires you to open the forecast chart manually through the Analyze then Forecast Charts command The default is True DisplayWhileRunning Variant True or False Used only when DisplayAuto is set to True True for this Optional parameter opens the forecast window at the start of a simulation False opens the forecast window at the end of a simulation The default is True Obsolete WindowSize n a n a This parameter formerly WindowSi ze is obsolete and is no Optional longer available for use However if you use one of the following option
283. o Crystal Ball forecasts for further analysis This call runs the Data Analysis tool and displays results without using a dialog Note Before calling CB DataAnalysisND reset the Crystal Ball simulation Table 44 CB DataAnalysisND Parameters Parameter Required VBA Data Type Table Index Required Integer Table 45 Value Optional Variant Table 46 Table 45 CB DataAnalysisND Index Parameter Required Integer VBA Data Index Named Constant Value Type Value Description cbDataAnalysisRun Integer 1 Runs the Data Analysis tool when all settings are complete cbDataAnalysisSelectData Integer 2 Selects the numeric portion of the data to be imported The range can either be specified as a separate line preceding the CB DataAnalysisND call such as A1 C100 Select or it can be the Value parameter specified as A1 C100 or similar cbDataAnalysisDataOrientation Integer 3 Works with Value to specify whether data is in rows or columns cbDataAnalysisDatalnRows 1 cbDataAnalysisDatalnColumns 2 cbDataAnalysisSelectHeaders Integer 4 Uses a boolean value for the Value parameter to include column header text in the selection True include the top row of text 102 Crystal Ball Macro Calls Named Constant Value cbDataAnalysisSelectLabels VBA Data Type Integer Index Value Description Uses a boolean value for the Value parameter to include row label text in the selection True include
284. o return a boolean to indicate whether the assumption report includes full statistics True cbBftUseDistLocking 21 Returns a boolean to indicate whether parameter locking is switched on True cbBftOutputGoodnessOfFitAllStats 22 Returns a boolean to indicate whether all statistics should appear when a Goodness of Fit report is produced True cbBftFitDistLockParam 23 Returns the locked value of the specified distribution and parameter The following distributions from Table 55 can be used as Value1 Gamma distribution Location Shape parameters Lognormal distribution Location parameter Student s t distribution Degrees of Freedom parameter Weibull distribution Location Shape parameters Binomial distribution Trials parameter Hypergeometric distribution Trials parameter Use Value2 to specify the number of the target parameter cbBftOutputLocationCell 25 If cbBftOutputLocation 12 returns cbBftCurrentWorksheet 4 can be used to return the first cell of the output range in the upper left corner cbBftOutputGoodnessOfFitSheet 27 If coBftOutputGoodnessOfFitReport 17 returns True can be used to return the sheet name string of the report cbBftOutputAssumSheet 28 If cbBftOutputAssumReport 18 returns True can be used to return the sheet name string of the report cbBftOutputWorksheet 29 Returns whether the current sheet cbBftCurrentWorksheet 4
285. o return assumption statistics for the selected cell Table 95 CB GetAssumStat Index Parameter Values Required Integer Named Constant Value Index Value Description cbAsnTrials 1 Returns the number of trials cbAsmMean 2 Returns the mean cbAsmMedian 3 Returns the median cbAsmMode 4 Returns the mode cbAsmStdDev 5 Returns the standard deviation cbAsmVariance 6 Returns the variance cbAsmSkewness 7 Returns the skewness 154 Crystal Ball Macro Calls Named Constant Value Index Value Description cbAsmKurtosis 8 Returns the kurtosis cbAsmCV 9 Returns the coefficient of variation cbAsmRangeMin 10 Returns the range minimum cbAsmRangeMax 11 Returns the range maximum cbAsmRangeWidth 12 Returns the range width cbAsmStdError 13 Returns the standard error cbAsmBaseCase 14 Returns the base case initial value of the forecast cell CB GetAssumStat Example 1 This example runs a simulation of 1000 trials and then pastes the standard deviation of the assumption in B7 into cell M6 In a macro you can enter CB Simulation 1000 Range M6 Value CB GetAssumStat Range B7 CB GetAssumStat Example 2 This example before a simulation displays 0 in the cell After a simulation it displays the standard deviation of the assumption in B7 In a worksheet cell you can enter CB GetAssumStatFN B7 5 False CB GetAssumStat Related Calls CB EnumAssum Descripti
286. o summarizes the structure of the Developer Kit and introduces CB Com Devkit chm a help file that serves as an online reference to the classes methods properties and other elements of the Predictor Developer Kit Specific Requirements for Use If you have a license to run Oracle Crystal Ball Crystal Ball Decision Optimizer or Oracle Crystal Ball Enterprise Performance Management you can use the Predictor Developer Kit and run applications built with it The following sections outline specific requirements for its installation and use Installing the Predictor Developer Kit The Predictor Developer Kit is automatically available when you install any of the Crystal Ball products version 11 1 1 3 00 or later and is immediately available for your use For installation instructions see the current Oracle Crystal Ball Installation and Licensing Guide 294 Using the Predictor Developer Kit Microsoft NET Framework Version The Predictor Developer Kit has been tested to run properly with Microsoft NET Framework Versions 2 0 3 0 and 3 5 You can force the Predictor Developer Kit to run against a specific version of the NET Framework using an application configuration file in the form of lt appname gt exe config placed in the folder of the application s executable The following section forces the Predictor Developer Kit code to run against Microsoft NET Framework 2 0 lt configuration gt lt startup gt lt supportedRuntime
287. ode must first set the cell selection to point to both the assumption cell and a table containing the custom data points You can do this using the Union object with the Range object to append the table s cell range to the assumptions cell location Even if set LowCutOff and HighCutoff are ignored for custom distributions 116 Crystal Ball Macro Calls Parm1 can only be set to cumulative True if the table of data points has two three or four columns Call CB MacroResult afterwards to determine whether the command was successful For more information about defining custom distributions using a data range see the Oracle Crystal Ball User s Guide CB DefineAssumND Custom Distribution Example This example selects cell B3 and the range D17 to G22 CB DefineAssumND interprets the data located in this second range of cells using the format described in the discussion of custom distributions in the Oracle Crystal Ball User s Guide Union Range B3 Range D17 G22 Select CB DefineAssumND cbDfaCustom False Sales CB DefineAssumND Related Calls Name Description CB CorrelateND Defines a correlation coefficient between two selected assumptions CB DefineAssum Defines or changes assumptions in selected cells using a dialog CB GetAssum Retrieves information for a specific assumption cell CB SetAssum Changes certain attributes for the assumption in a cell CB DefineAssumFromForeND This subroutine de
288. ode runs the Data Analysis tool CB ResetND Select data in cells B1 through D100 CB DataAnalysisND cbDataAnalysisSelectData Set input range orientation CB DataAnalysisND cbDataAnal Input range has headers CB DataAnalysisND cbDataAnalysisSelectHeaders True Automatically open forecast charts CB DataAnalysisND cbDataAnalysisAutoOpenCharts True Fit to distribution CB DataAnalysisND cbDataAna Select the Chi square ranking method CB DataAnalysisND cbDataAnalysisRankingMethod Run tool CB DataAnalysisND cbDataAnalysisRun B1 D100 data in columns lysisDataOrientation lysisFitToDistribution True cbFitChiSquare cbDataAnalysisDataInColumns CB DataAnalysisND 105 CB DataAnalysisND Related Calls Name Description CB DataAnalysis Launches the Data Analysis tool CB GetDataAnalysisOption Returns current settings for the Data Analysis tool CB DecisionTable This call launches the Decision Table tool wizard This tool runs multiple simulations to test different values for one or two decision variables The tool tests values across the range of the decision variables and puts the results in a table that you can analyze using Crystal Ball forecast trend or overlay charts Note Before calling CB DecisionTable reset the simulation CB DecisionTable Example This example resets Crystal Ball and opens the Decision Table wizard CB Reset CB DecisionTable CB
289. of 1 00 an upper bound of 3 00 and is defined as a Discrete decision variable with a step size of 1 00 Notice that this definition yields three values expressed as integers 1 2 and 3 These are not numeric values but instead they represent three different remediation methods for groundwater cleanup This example model was included with Crystal Ball before new decision variable types were added Starting with Crystal Ball 11 1 1 0 00 this decision variable can be defined as the Category type shown in the following code Range D13 Select CB DefineDecVarND 1 3 1 Remediation Method cbDecVarTypeCategory This code defines a new decision variable in cell D13 that is identical to the one in Groundwater Cleanup xls except for the decision variable type It has a lower bound of 1 an upper bound of 3 a step size of 1 a title of Remediation Method and a decision variable type of Category Although a step size is entered for this decision variable type it is ignored CB DefineDecVarND Example 5 This example defines a new decision variable in cell G8 with a lower bound of 10 an upper bound of 40 no step size a title of Net Income and a decision variable type of Custom The values of Min and Max are ignored for Custom decision variables but they must be entered since they are required parameters for CB DefineDecVarND If a step size is entered for this decision variable type it is ignored Range G8 Select CB DefineDecVarND
290. of data in column D and then calls CB Fit in a For loop The loop fits each distribution to the range of data saving the best distribution index in bestdist and the corresponding Anderson Darling p value in bestfit CB SetFitRange Range D4 D104 For i 0 To 23 Result CB Fit i cbFitAndersonDarling True If i 0 Then bestfit result Else If bestfit gt result Then bestdist i bestfit result End If End If Next i CB Fit Example 3 This example filters the input data automatically selects distributions and ranking methods and then reports the best fit CB SetFitRange A1 A1000 Dim DistBestFit As Integer Dim CritBestFit As Integer Filter data in the Microsoft Excel input range A1 A1000 to include only values between 10 and 10 CB SetFitFilter True False 10 10 Result cb Fit cbDfaAutoSelectDist cbDfaAutoSelectRankingMethod False _ DistBestFit CritBestFit Write results the Goodness Of Fit stat and the best fitted distribution 142 Crystal Ball Macro Calls Sheet1 Cells 4 4 Value Result Sheet1 Cells 5 4 Value DistBestFit Sheet1 Cells 6 4 Value CritBestFit CB Fit Example 4 This example fits a dataset to a gamma distribution while locking the location and shape parameter First fit with locking set but switched off Location is locked to 0 and shape to 3 CB SetFitRange A1 A30 Fit to a gamma distribution Switch off all the locked parameters CB LockFitParm cbDfaGa
291. ok which includes but is not limited to inserting and deleting rows columns and individual cells Other examples of when to use the CheckData calls include each time you start a new enumeration use a CB Get call that relies on cell references that might have changed and before using calls that extract data or create reports CB CheckData Example This example runs a simulation of 500 trials initializes all the internal variables for the following enumeration and then enumerates all the forecasts opening each forecast chart Dim s As String Dim r As Range CB Simulation 500 CB CheckData s CB EnumFore While s lt gt Set r Range s CB OpenFore 74 Crystal Ball Macro Calls s CB EnumFore t t 1 Wend CB CheckData Related Calls Name Description CB CheckDataND Checks Crystal Ball data cells for validity initializes variables without error prompting CB EnumAssum Enumerates assumption cells for all open workbooks CB EnumFore Enumerates forecast cells for all open workbooks CB EnumDecVar Enumerates decision variable cells for all open workbooks CB CheckDataND Subtopics e CB CheckDataND Example 1 e CB CheckDataND Example 2 e CB CheckDataND Related Calls Like CB CheckData this subroutine scans Crystal Ball data on open worksheets checking the validity of all Crystal Ball data objects including assumptions decision variables forecasts and correlations Then it initializes inte
292. ol CB BootstrapND Runs the Bootstrap tool without displaying dialogs CB GetCBAutoLoad In Crystal Ball 7 3 x or 11 x you can use the following alternatives to determine whether Crystal Ball launches each time Microsoft Excel starts called autoloading e Startthe Crystal Ball Application Manager and check or uncheck When starting Microsoft Excel automatically launch Crystal Ball e Open the Microsoft Excel COM Add ins dialog and check or uncheck Crystal Ball e Include the CB SetCBAutoLoad call CB SetCBAutoLoad on page 227 in Visual Basic or VBA code with the autoLoad parameter set to True or False Whichever alternative you use the same setting appears in both of the other two alternatives For more information on these alternatives see Starting Crystal Ball in the current Oracle Crystal Ball Installation and Licensing Guide 160 Crystal Ball Macro Calls CB GetCBAutoLoad returns the current autoload setting True if Crystal Ball is set to automatically load each time Microsoft Excel opens or False if Crystal Ball is not set to autoload Table 106 CB GetCBAutoLoad Returned Data Type Returned Value Returned Data Type The current autoload setting Boolean CB GetCBAutoLoad Example To retrieve the current Crystal Ball autoload setting use this call in a function in the following form ReturnValue CB GetCBAutoLoad CB GetCBAutoLoad Related Calls Name Description CB CBLo
293. omial D 16 probability shape whole number n a n a between O and 1 greater than O and less than 1000 cbDfaHypergeometricSuccess D 17 success trials whole number population n a less than population whole number greater than 0 and less than 1000 cbDfaMinExtreme C 18 likeliest scale greater than 0 n a n a cbDfaMaxExtreme C 19 likeliest scale greater than 0 n a n a cbDfaStudentsT C 20 midpoint scale greater than O degrees of n a freedom integer between 1 and 30 inclusive cbDfaYesNo D 21 probability n a n a n a cbDfaDiscreteUniform D 22 minimum integer maximum integer n a n a cbDfaBetaPert C 23 minimum likeliest maximum n a Note cbDfaHypergeometric is deprecated It is included for Crystal Ball 2000 5 5 5 compatibility and is replaced by cbDfaHypergeometricSuccess in later versions of Crystal Ball cbDfaExtremeValue is deprecated It is included for Crystal Ball 2000 5 5 5 compatibility and is replaced by cbDfaMinExtreme and cbDfaMaxExtreme in later versions of Crystal Ball CB DefineAssumND 115 To define an assumption parameter with a dynamic cell reference specify the cell reference as a string See the Oracle Crystal Ball User s Guide for more information on distribution types and parameters The active cell must contain a numerical value or be blank If it contains anything other than a numerical value such as an expression a cell reference or text CB MacroResult returns cbEr
294. on Enumerates assumption cells for open worksheets CB GetAssum Retrieves information for a specific assumption cell CB GetAssumPercent Returns percentiles for assumption cells CB Simulation Runs a Crystal Ball simulation CB GetBatchFitOption This function returns specified settings made by CB BatchFitND or the Batch Fit tool cbAsmStdDev CB GetBatchFitOption 155 Table 96 CB GetBatchFitOption Returned Data Type Returned Value The specified Batch Fit settings Returned Data Type Variant Table 97 CB GetBatchFitOption Parameters Required Integer Parameter Required VBA Data Type Table Index Required Integer Table 98 Valuel Optional Variant Table 99 Value2 Optional Variant Table 100 Table 98 CB GetBatchFitOption Index Parameter Required Integer Index Named Constant Value Value Description cbBftinputRange 1 Returns a string with the address of the selected Batch Fit data range in the format workbook sheet A 1 Z 100 cbBftinputOrientation 2 Returns a constant to indicate whether the data cells are in rows or columns cbBftinputRows 1 or cbBftInputColumns 2 cbBftinputHeader 3 Returns a boolean to indicate whether the input range has a header True cbBftinputLabel 4 Returns a boolean to indicate whether the input range has a label True cbBftSelectDist 5 Returns an array of cbDfa assumption distribution integers
295. on Returns a range of custom percentile values in the range specified with Value For Index 6 cbBtsSample Integer cbBtsNumberSamples 1 Used with cbBtsSample to return the number of bootstrap samples to use For Index 6 cbBtsSample Integer cbBtsTrialsPerSample 2 Used with cbBtsSample to return the number of trials to run for each bootstrap sample CB GetBootstrapOption 159 Table 105 CB GetBootstrapOption Value Parameter Optional Variant Related Value VBA Data Type Description For Index2 7 A string containing a Microsoft Excel range to Used with cbBtsPercent and cbBtsPercentCustom to cbBtsPercentCustom Variant holds a set of returned custom percentile return custom percentile values and place them within values the specified range CB GetBootstrapOption Example 1 This example returns the percentile setting used in the Bootstrap tool definition For this example the returned type would be cbBtsPercentCustom CB GetBootstrapOption cbBtsPercent CB GetBootstrapOption Example 2 This example returnsa set of custom percentile values for example those stored in the Microsoft Excel range F17 H17 as shown in CB BootstrapND Example 1 The returned values are placed in the specified range in this case F20 H20 CB GetBootstrapOption cbBtsPercent cbBtsPercentCustom F20 H20 CB GetBootstrapOption Related Calls Name Description CB Bootstrap Launches the Bootstrap to
296. on the forecast must exist Table 195 CB SetFore Returned Data Type Returned Value Returned Data Type Whether the function was successful Variant Table 196 CB SetFore Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 Points to the forecast cell with the desired data Index Integer See Table 197 Sets certain forecast attributes according to va1ue Value Variant See Table 198 Works with Index to set certain forecast attributes Table 197 following describes the Index parameter Table 197 CB SetFore Index Parameter Values Required Integer Named Constant Value cbForName Index Value Description 1 Sets the forecast name according to Value cbForUnits 2 Sets the forecast units according to Value 232 Crystal Ball Macro Calls Named Constant Value Index Value Description cbForAutoOpen 4 Changes whether Crystal Ball displays the forecast window automatically according to Value cbForOpenWhen 5 Changes when Crystal Ball displays the forecast window according to Value cbForPrecision 6 Changes whether Crystal Ball uses precision of the forecast value to stop a simulation according to Value cbForPrecisionAbsolute 7 Changes whether Crystal Ball uses absolute or relative terms for the size of the confidence interval according to Value cbForPrecisionAbsolut
297. on s case cbErrBadAssumption MsgBox Invalid assumption parameter s case cbErrCallingDLL MsgBox Could not find the DLL case cbErrUnexpected MsgBox An unexpected error occurred End Select End Sub CB MacroResult 193 CB MacroResult Related Call Name Description CB MacroResultDetail Indicates if a macro call worked correctly including detailed error information CB MacroResultDetail This function returns detailed information about whether other Crystal Ball macro calls worked correctly and can include additional information for compatibility and diagnostic purposes Table 158 CB MacroResultDetail Returned Data Type Returned Value Returned Data Type The value of the specified property of CBMacroResultDetail as indicated in Table 159 on page 194 Variant CB MacroResultDetail is different from other Developer Kit subroutines and functions because its parameters are properties of a type class instead of constants See the example for appropriate syntax Table 159 CB MacroResultDetail Properties Property VBA Data Type Description OldValue Integer The value returned by CB MacroResult listed in Table 160 NewValue Integer The value returned by CB MacroResultDetail NewValue in this version of Crystal Ball Msg String A string that summarizes the error MsgDetails String A message with more information about the error MsgTitle String The command for which these results are ret
298. on values Note The constant cbDatForeValues is included for compatibility with Crystal Ball 2000 5 5 5 and is considered deprecated in later versions of Crystal Ball for future compatibility use CBDatValues instead cbDatValues 1 Extracts forecast and assumption values same as cbDatForeValues but name reflects capabilities more accurately cbDatStatistics 2 Extracts statistics cbDatPercentiles 3 Extracts percentiles cbDatFrequencies 4 Extracts the number of data points in each chart bin cbDatSensitiv 6 Extracts sensitivity data cbDatCapMetrics 7 Extracts capability metrics data True extracts the metrics and False does not extract the metrics cbPctSet3 7 Extraction of the 5 and 95 percentiles Note The constant coDatCumulative 5 is not included in this release The following values are used with Index cbExtChooseFore to specify forecast data for extraction 136 Crystal Ball Macro Calls Table 71 Value Parameter Values that Support Index Constant cbExtChooseFore Named Constant Value Index Value Description cbChfAll 1 Includes all forecasts cbChfOpen 2 Includes open forecasts cbChfChosen 3 Includes chosen forecasts Use after cbChfAdd cbChfAdd 4 Adds the forecast in the selected cell to the list of chosen forecasts Use cbChfChosen after this option Note An error is returned if the user attempts to add cbChfAdd a forecast which contains no underlying data During extraction only those
299. or GoToorOn Error Resume Next For example consider the following code sample from OptDevKitRuntimeSample xls on page 284 On Error GoTo ErrorHandling This means that when an error condition occurs the ErrorHandling code is called Then ShowError is called and a series of messages describe the detected error For details look at the codein OptDevKitRuntimeSample xls and search for ShowError Also look up CB MacroResult and CB MacroResultDetail in the Crystal Ball Developer Kit User Manual Accessing OptQuest with the Crystal Ball Developer Kit The object instantiation in OptDevKitRuntimeSample xls on page 284 uses the Set New syntax to create objects in the CBCOMDevKit namespace 286 Using the OptQuest Developer Kit Set PortfolioOptSetup New CBCOMDevKit OptSetup Set PortfolioOptRuntime New CBCOMDevKit OptRuntime You can also create and use these objects outside of that namespace with the following Crystal Ball Developer Kit calls e CB OptSetup e CB OptRuntime To do this you must reference CBDevKit as well as CBCOMDevKit Then you can use Visual Basic or VBA syntax to apply methods and properties For example CB OptSetup Show can be used in Visual Basic or VBA code to display the OptQuest wizard User defined Event Macros for Optimizations This section summarizes information about user defined Microsoft Excel VBA event macros that can run at various times while an OptQuest optimization runs User de
300. or new sheet cbBftNewWorksheet 3 is being used for the Batch Fit output cbBftOutputOrientation 30 Returns a constant to indicate whether the output is in rows or columns cbBftOutputRows 1 or cbBftOutputColumns 2 cbBftOutputSheetName 31 Returns the name of the worksheet containing primary fit results assumptions as a string Table 99 CB GetBatchFitOption Value1 Parameter Optional Variant Used With Specified Values of Index For Index 23 cbBftFitDistLockParam Variant Index Named Constant or Boolean Value Value Description One of the cbDfa distribution names for the n a Returns the locked value of the following distributions from Table 55 gamma specified distribution and the lognormal Student s t Weibull binomial parameter specified with hypergeometric Value2 CB GetBatchFitOption 157 Table 100 CB GetBatchFitOption Value2 Parameter Optional Variant Used With Specified Values Named Constant or Boolean Index of Index Value Value Description For Index 23 One of the parameter numbers n a Returns the locked value of the specified parameter for the cbBftFitDistLockParam from Table 55 for the distribution specified with va1uez The numbers listed for Integer distribution specified with the following parameters in Table 55 can be used for Value1 gamma lognormal Value2 Student s t Weibull binomial m hypergeometric e Gamma distribution Locatio
301. orkbooks CB GetDecVar Retrieves information for a specific decision variable cell CB EnumFore This function enumerates forecast cells for all open workbooks This command is useful for determining what forecasts have been defined for the open worksheets You can then call CB GetFore for each forecast to retrieve specific information for example the forecast name and units CB EnumFore 131 Table 67 CB EnumFore Returned Data Type Returned Value Returned Data Type The absolute cell reference of the next forecast in the format workbook sheet A 1 Variant Note Call CB CheckData once at the beginning of an enumeration to reset the sequence of forecasts Call CB CheckData each time you add or delete data or perform other calls that restructure the worksheet Use CB CheckData or CB CheckDataND with CB MacroResultDetail to check for errors For more information see the descriptions of those calls If the return string is empty all forecasts have been enumerated You can use the results of this function to create a Range object You can only call this function from a subroutine or another function You cannot call this function from a worksheet CB EnumFore Example This example runs a simulation initializes all internal variables and then steps through all the forecasts creates range objects from the returned string and opens the forecast window for each one Note that the range objects are created wi
302. page 163 162 Crystal Ball Macro Calls Note For best results call CB CheckData before calling this function to ensure the latest data values are used Table 109 CB GetCorrelation Returned Data Type Returned Value Returned Data Type The correlation coefficient of the two assumptions Variant If a correlation between the assumptions was not defined this function returns the value 2 Table 110 CB GetCorrelation Parameters Parameter VBA Data Type Value Description AssumReference Variant In a macro Range B3 Points to one of the correlated assumption cells Column Integer Any number up to 256 Points to the column of the second correlated assumption Row Long Any number up to 64 000 Points to the row of the second correlated assumption CB GetCorrelation Example This example puts the correlation coefficient between G8 and G15 into cell H15 In a macro you can enter CB CheckData Range H15 Value CB GetCorrelation Range G8 7 15 CB GetCorrelation Related Calls Name Description CB CorrelateND Defines a correlation coefficient between two selected assumptions CB GetAssum Retrieves information for a specific assumption cell CB GetCorrelationByRef Returns the correlation between two assumption cells with fewer parameters cells can be on two different worksheets CB GetCorrelationByRef This function returns the correlation coefficient defined between two as
303. page 201 CB ResetND on page 201 CB SelectAssum on page 219 CB SelectDecVar on page 220 Crystal Ball Developer Kit Overview e CB SelectFore on page 221 e CB SetAssum on page 225 e CB SetCBWorkbookPriority on page 227 e CB SetDecVar on page 228 e CB SetFitFilter on page 231 e CB SetFitRange on page 231 e CB SetFore on page 232 e CB Simulation on page 238 e CB SingleStep on page 240 e CB StartMultiSimul on page 240 e CB StopMultiSimul on page 242 e CB WorksheetProtection on page 250 Controlling Crystal Ball Chart Windows The macro calls in this group can be used to e Select which chart windows to open or close e Open charts for selected cells The following sections describe calls that are used to control Crystal Ball windows e CB CloseAllCharts on page 79 e CB CloseChart on page 79 e CB CloseFore on page 80 e CB CloseSensitiv on page 81 e CB CloseTrend on page 82 e CB OpenChart on page 196 e CB OpenFore on page 197 e CB OpensSelection on page 198 e CB OpenSensitiv on page 198 e CB OpenTrend on page 199 Managing Charts The macro calls described in the following sections can be used to perform chart management tasks such as creating charts copying charts enumerating or listing charts and deleting charts e CB CopyScatter on page 84 Controlling Crystal Ball Chart
304. parameter after setting other extract options cbExtDataType See Table 70 Specifies the type of data to extract Used with these Value parameter values described in Table 70 1 cbDatForeValues CB 2000 x or 5 x only 1 cbDatValues CB 7 x and 11 x or later 2 cbDatStatistics 3 cbDatPercentiles 4 cbDatFrequencies 6 cbDatSensitiv 7 cbDatCapMetrics cbExtChooseFore See Table 71 Specifies which forecasts to include Used with these Value parameter values described in Table 71 1 cbChfAll 2 cbChfOpen 3 cbChfChosen 4 cbChfAdd 5 cbChfClearList cbExtPercentiles See Table 72 Specifies which percentiles to extract Used with these Value parameter values described in Table 72 1 cbPctQuartiles 2 cbPctQuintiles 3 cbPctDeciles 4 cbPctlcosatiles 5 cbPctSet1 6 cbPctSet2 7 cbPctSet3 8 cbPctSet4 cbExtExistingSheet True or False True extracts data to a new worksheet called Data in the active workbook False extracts data to a new worksheet called Data in a new workbook cbExtChooseAsm See Table 73 Specifies which assumptions to include Used with these Value parameter values described in Table 73 1 cbChaAll 2 cbChaChosen 3 cbChaAdd 4 cbChaClearList 5 cbChaOpen cbExtChartBins A value between 10 and 1000 Indicates how many bins value groups or intervals to include Note This value is independent of the Chart Prefe
305. penFore Example Ead d EA ad RET AAA RU AER sws T97 CB OpenFore Related Calls occsscscaveva A En CB Openselection 22 ee er Ried ideas 198 A HELM 198 LR Ded Deed OU AAA 198 CIOpenSensidiv oisuacs cce ua A ies 198 GRIEF RISE Ligas es eed ERE AC EG CUR AA 198 Contents xi CB OpenSensitiv Related Calls re ee UR nema er s 199 LIBET a ioci porq dai 95 dco ORE ERR alode od eee sa 199 CB OpenTrend Example caccini ide uice oed Se adt equ bpte dide 199 CB OpenTrend Related Calls precede EE E EEE Re abe ere 199 CASAR rcm 199 CB PasteData Example 1 A Pas tad dex dt Ma aca de acad 200 CB PasteData Example2 rcr Um E 200 CB PasteData Example3 abu M saa s 200 CB PasteData Related Calls AAA 201 ERE uudegedesuuuqpaesbeqiqas dra ad padded 201 LB Reset Example socero reces redd us bes sortate TP RSS 201 MAA Ch sns EYGAA GOES ERA Fia ER dab A VUE RO 201 CBReseli ND rl aa A EER 201 CE Reset Espaplo voracidad EA IRA 202 CB BUD ODA cp CE COR ae de e ee orae is A A d pene iuebessqgeubeeQdu bp REx e Vd psseaq dis 202 CB RestoreResults Example E A t qi eiie ns 203 CB RestoreResults Related Calls pius oe bus 25 xus Re bus core 203 CARA rhe hoe phen each ADA 1o e Ro a d e Oe CE Restore Resit ND Example RARA RARA IRA 203 CB RestoreResultsND Related Calls ERES e ids T n Abad T 204 a 47 Crece rm CB uo ia
306. penSensitiv 198 267 CB OpenTrend 199 267 CB OptRuntime 287 CB OptSetup 287 CB OptSetup Show 287 CB PasteData 199 267 CB Reset 201 CB ResetND 201 CB RestoreResults 202 CB RestoreResultsND 203 CB RunPrefs 204 CB RunPrefsND 204 268 CB RuntimeMode 32 209 CB SaveResults 210 CB SaveResultsND 210 CB ScatterPrefs 211 CB ScatterPrefsND 212 CB ScenarioAnalysis 215 CB ScenarioAnalysisND 216 CB SelectAssum 219 CB SelectChart 219 CB SelectDecVar 220 CB SelectFore 221 CB SensPrefs 221 CB SensPrefsND 222 268 CB SetAsmSensitivityChartGroup 224 CB SetAssum 225 269 CB SetCBAutoLoad 227 A B C D E F G H I CB SetCBWorkbookPriority 227 CB SetDecVar 228 269 CB SetFitFilter 231 CB SetFitRange 231 CB SetFore 232 269 CB SetMicrosoft Excel2007ForegroundMode 230 CB SetRange 235 CB Shutdown 237 CB SimResult 237 269 CB Simulation 238 270 CB SingleStep 240 CB Spearman 67 CB StartMultiSimul 240 270 CB Startup 242 CB StopMultiSimul 242 CB TrendPrefs 243 CB TrendPrefsND 243 270 CB TwoDSimulation 246 CB TwoDSimulationND 247 CB WorksheetProtection 250 cells freezing 147 cells CB preferences 68 69 certainties getting CB forecast 161 chart windows 41 charts closing 79 81 82 copying 84 85 86 creating 90 deleting 125 listing 127 managing 41 Microsoft Excel 98 opening 196 198 199 preferences 211 212 221 222 243 selecting 219 classes important OptQuest Develope
307. peration required all worksheets to be saved but one or more sheets were not saved cbErrNoCBSheets 9 There were no worksheets with Crystal Ball information to save cbErrRestoreResult 10 Restore Results failed cbErrTooManyAssumptions 11 Crystal Ball can store no more assumptions cbErrTooManyForecasts 12 Crystal Ball can store no more forecasts cbErrBadCorrelation 13 One or more correlations were invalid cbErrBadAssumption 14 One or more assumption parameters were invalid cbErrUnexpected 101 An unexpected error occurred such as a formula cell was used for a macro that required a single value cell CB MacroResultDetail Example This subroutine checkresult clears the specified range defines a normal distribution in cell A1 defines a forecast in cell A2 runs a simulation and displays a dialog for each of the CB MacroResultDetail properties Then it clears the Crystal Ball data in cells Al and A2 and stops Sub checkresult Range A1 A2 Select CB ResetND CB ClearDataND Range A1 A2 Clear Range A1 Select ActiveCell Value CB DefineAssumND cbDfaNormal Range A2 Select ActiveCell Value CB DefineForeND CB Simulation 1000 LAU 1 MsgBox CB MacroResultDetail DialogResult MsgBox CB MacroResultDetail ElapsedTimeInMS CB MacroResultDetail 195 MsgBox C MsgBox C MsgBox C MsgBox C CB ResetND CB ClearDataND End Sub Range A1 A2 Select Range A1 A2
308. ple 1 The following example returns a string with the address of the selected data range CB GetDataAnalysisOption cbDataAnalysisSelectData CB GetDataAnalysisOption Example 2 The following example returns the current view setting for forecast charts generated by the Data Analysis tool CB GetDataAnalysisOption cbDataAnalysisSetViewType CB GetDataAnalysisOption Related Calls Name Description CB DataAnalysis Launches the Data Analysis tool CB DataAnalysisND Runs the Data Analysis tool without displaying dialogs CB GetDecisionTableOption This function returns specified settings made by CB DecisionTableND or the Decision Table tool Table 115 CB GetDecisionTableOption Returned Data Type Returned Value Returned Data Type The specified Decision Table settings Variant Table 116 CB GetDecisionTableOption Parameters Parameter Required VBA Data Type Table Index Required Integer Table 117 Index2 Optional Integer Table 118 166 Crystal Ball Macro Calls Table 117 CB GetDecisionTableOption Index Parameter Required Integer Named Constant Index Value Value Description cbDecGetTarget 1 Returns a string with the address of the target forecast in the format workbook sheet A 1 cbDecGetDecVar 2 Returns a string with the address of the selected decision variable in the format workbook sheet A 1 Must be used with Index2 cbDecVar1 or cbDecVar2 to indicat
309. ponential C 6 rate greaterthan 0 n a n a n a cbDfaGeometric D 7 probability n a n a n a between 0 and 1 cbDfaWeibull C 8 location scale greater than 0 shape greater n a than 0 05 cbDfaBeta C 9 alpha greater than beta greater than O maximum value minimum value 0 3 alpha beta 3 alpha beta must must be less than be less than 1000 1000 cbDfaHypergeometric D 10 probability trials whole number population n a between 0 and 1 less than population whole number greater than 0 and less than 1000 114 Crystal Ball Macro Calls DistType Parameter Named DistType Parm4 Constant Value C continuous Parameter Parm3 Description D discrete Index Value Parm1 Description Parm2 Description Description Optional cbDfaCustom See Defining 11 cumulative True or sequential sampling n a n a Custom Distributions on page noncumulative True or 116 C D False False is the nonsequential default sampling False see the section on SIPs in the Oracle Crystal Ball User s Guide cbDfaGamma C 12 location scale greater than O shape greater n a than 0 05 and less than 1000 cbDfaLogistic C 13 mean value scale greater than 0 n a n a cbDfaPareto C 14 location greater shape greaterthan O n a n a than 0 05 cbDfaExtremeValue C 15 likeliest scale greater than 0 max True or min n a False cbDfaNegBin
310. ption Returned Data Type Returned Value Returned Data Type The specified Data Analysis settings Variant CB GetDataAnalysisOption has one parameter Index which is a required integer See Table 114 for details 164 Crystal Ball Macro Calls Table 114 CB GetDataAnalysisOption Index Parameter Required Integer VBA Data Index Named Constant Value Type Value Description cbDataAnalysisSelectData Integer 2 Returns a string with the address of the target forecast in the format workbook sheet A 1 cbDataAnalysisDataOrientation Integer 3 Returns one of two possible values for the data orientation cbDataAnalysisDatalnRows 1 cbDataAnalysisDatalnColumns 2 cbDataAnalysisSelectHeaders Integer 4 Returns a boolean value to indicate if column header text is in the selection True cbDataAnalysisSelectLabels Integer 5 Returns a boolean value to indicate if row label text is in the selection True cbDataAnalysisSelectLSL Integer 6 Returns the range of values selected as forecast LSLs lower specification limit for process capability analysis The range is a string in the format workbook sheet A 1 cbDataAnalysisSelectUSL Integer 7 Returns the range of values selected as forecast USLs upper specification limit for process capability analysis The range is a string in the format workbook sheet A 1 cbDataAnalysisSelectTarget Integer 8 Returns the range of values selected
311. r 36 Specifies the order ofthe report String A string of ten n a sections comma separated values listed in Table 42 that is ME B specify the section order For es i Es ae example 1 6 7 8 2 3 4 5 9 Sp eC nen 10 indicates that the report should include sections in this order Summary Forecasts Assumptions Decision Variables Overlay Trend Sensitivity Scatter OptQuest results Predictor forecasts cbRptCapMetrics 37 Specifies whether to report True includes the metrics n a capability metrics for forecasts False does not include the in custom reports metrics cbRptScatterChart 38 Includes all open scatter charts Boolean True includes the Integer 1 to 200 in the report at a specified chart False does not defines the percent scale scale of the chart cbRptOptimizersummary 39 Includes the OptQuest Boolean True includes the n a Summary section in the report OptQuest summary following an optimization run information False does not cbRptOptimizerChart 40 Includes the optimization Boolean True includes the Integer 1 to 200 solution graph in the report chart False does not defines the percent following an optimization run scale of the chart cbRptOptimizerBestSolution 41 Includes the OptQuest Best Boolean True includes the n a Solution section in the report OptQuest best solution following an optimization run information False does not cbRptOptimizerConstraints 42 Includes the OptQuest Boolean True inc
312. r Kit 279 optimization runtime 280 optimization setup 279 OptRuntime 281 OptRuntime OptCounters 281 OptRuntime OptSolution 281 OptRuntime OptVarSolutionFilter 281 OptRuntime OptVarStatistics 281 OptRuntime ResultsWindow 281 M N O P R S TU VW OptRuntime RuntimeEfficientFrontier 281 OptRuntime TestPointInfo 281 OptSetup 280 OptSetup Constraint 280 OptSetup Decision 280 OptSetup Objective 280 OptSetup OptEfficientFrontier 280 OptSetup OptOptions 280 OptSetup Requirement 280 Predictor Developer Kit 295 Predictor setup 296 PredResults 297 PredResults PredResultsPreferences 297 PredResults PredResultsWindow 297 PredResults PredSeriesResult 297 PredSetup 296 PredSetup PredDataAttributes 296 PredSetup PredInputData 296 PredSetup PredMethods 296 PredSetup PredOptions 297 PredSetup PredSeries 297 clearing CB data 77 78 closing CB forecasts 80 charts 79 81 82 code development OptQuest 282 coding optimization 285 constraints and macros 291 consulting 23 contact information 23 copying CB data 82 83 charts 84 85 86 correlating assumptions 67 86 88 correlations enumerating 128 correlations getting for two assumptions 162 163 creating a Microsoft Excel add in 28 assumptions 112 113 117 CB forecasts 123 charts 90 decision variables 119 120 reports 91 92 Crystal Ball starting manually 23 Index 301 A B C DEF Crystal Ball Developer Kit 286 Crystal Ba
313. r PpTC 204 CB BunPrets Related Calls 224 sess sdesasesose pub e dada 204 CB RunPreBND 2 6 a Eres TEE TT A TREE PT Sres 204 LI i er Ecler RARA X PX ES 208 CB Run PrersNI Explore rk C RESKR MK EE X REDUCE 208 CB RunPrefsND Related Calls T OS TOW eae aback TS TW ee 209 LB Rute ede caa eee eee Ate Te EO de o deo de ale p gota ee 2 CIMA DONNE osse pe A RE RARE EpL westerns 209 CIL Mune AA 209 ER arches coon rop edu EP PER RERO EE RE RPeT ERI Reb RE Ed ard eed 210 CB SaveResults Example Cre TC Peer 210 Ch cave Resale Related Calls ta nd dhe EC pedo C bg o do 210 CB SaveResultsND S ee ee ee TOT eee Ros TP EE 210 LE Save Repl END Epe 4 ceguera E engage Ex ge KO de Jed gero s 211 CD SayeResults ND Related Calls 1 isuoacacleau arr RIP RDRREE OPES 211 CP Seater Piers sicario airada toria 211 ia MAA 211 CB ScatterPrefs Related Call NM pede E RE ee Be ad S 212 COPAN bos ne gh eke a eek lo E OR ER CB SatierPre RND Example 212425 eee eke oboe A 214 CB ScatterPrefsND Related Call nn s 215 A aed ep ERA Roe odia RP da EROR a Eed AERA REA E WS sd LB oon Hodie Example iii T 2 CBSceninolnalyss Related Calls A seen Paes dwave 216 CB ScenarioAnalysisND nee ee R uds 216 CB nnb sa UND Example rico eue 218 CB ScendtioAnalysisND Related Calls 1225522402222992 922 4 Rue ERE VEA 219
314. r cbFullBuildVersion in the previous example the maximum value for Index in this example would be 4 If Index 0 or is not specified the full string for VersionType is returned CB GetVersion Example For Crystal Ball version 11 1 1 0 00 this example places the string 11 1 1 0 00 in cell A2 and a string with the full build number 11 1 63 0 into cell B2 Range A2 Value Range B2 Value CB GetVersion CB GetVersion cbFullBuildVersion CB GetVersion Related Calls Name CB GetWorksheetVersion Description Returns the Crystal Ball data version of the active or specified worksheet CB GetWorksheetVersion This function returns the Crystal Ball data version ID or build number for the active or specified worksheet It has three optional parameters The first optional parameter Worksheet indicates the target worksheet If omitted information is returned for the active worksheet The second optional parameter VersionType and the third optional parameter Index can return the full or partial version ID or build number as a string Note For Crystal Ball versions 7 0 through 7 1 2 the version ID returned is 7 0 0 This string changed starting with data created by Crystal Ball version 7 2 Table 151 CB GetWorksheetVersion Returned Data Type Returned Value Returned Data Type The Crystal Ball data version ID or build number returned for the active or specified worksheet Variant
315. r era aca SCR GG iia 175 CB GetForeData Example 1 Pese eds ae 175 rte Daa Pe ee nk dq act Ap gale pq pae E DECIR Cassa whos Di A A AR A A eens A 176 CI GerPorePercent Example conan carino ria 176 CB GetForePercent Example2 dus beg ess ws TT sees sed CB GetForePercent Related Calli sida 177 CB GetForeStat icssuss ias Es ee Aa db d pd dd dede TE dd i ee iod te ss 177 CB GetForeStat Examplel ad ee dd L er Oley Ee Liu eaae ok oe ode eoe an d qe e Ro eod oae ao MER CB GetForeStat Related Calls ee ee ee eT ee ee 179 LB GetlockPHPAMM aros A A tK eiiis 180 CB GetLockFitParm Example Te or Fwd ee v IBI CB OoLodcupurm Related Cul iaa Luka Ra REA RRERE VERSA ORE 181 CB GetiunPrefs sosurnirniarndcar da pisa dE ed sl ibd dad END d 181 CB GetRunPrefs Example 1 rr vee ads ee 182 MA 182 CB GetRunPrefs Related Calls o0ccinorrrar ranas o EEE 182 CB GetScenarioAnalysis Option conca 182 CB GetScenarioAnalysisOption Example cscsisisisesseerisrsesen DOR CB GetScenarioAnalysisOption Related Calls i4 ads Sea 184 ee er OC DDR cua ua pour debo doe E Wo Pd or op AOR RES 184 CB GetTwoDSimulaionO ption Example 1 112244 2429939 axebRaerPraachwue va 187 CB GetTwoDSimulationOption Example2 bus 354 187 CB GetTwoDSimulationOption Related Calls ooooooooo o o sa
316. r more information on setting run preferences Table 163 CB RunPrefsND Parameters Parameter VBA Data Type Value Description Index Integer See Table 164 Works with the Value and value2 parameters to set Crystal Ball run preferences Valuel Variant See Table 165 Works with the Index parameter to set Crystal Ball run preferences Value2 Variant Any positive whole For Index 4 coRunSameRandoms Long Sets the initial seed value Optional number for the random number generator The following Index named constant and index values Table 164 work with the Value1 and Value2 parameters to set Crystal Ball run preferences 204 Crystal Ball Macro Calls Table 164 CB RunPrefsND Index Parameter Values Required Integer Index Named Constant Value Value Description cbRunMaxTrials 1 Sets the maximum number of trials to the number in va1ue1 cbRunStopOnError 2 Sets whether the simulation stops on calculation errors in forecast cells according to Valuel cbRunSameRandoms 4 Sets whether the random number generator uses the same sequence of random numbers Value1 and sets the initial seed value Value2 cbRunSamplingMethod 7 Selects whether to use the Latin Hypercube or Monte Carlo sampling method according to Valuel cbRunSampleSize 8 Sets the Latin Hypercube sampling method s sample size to Value1 cbRunCorrelationsOff 10 Sets whether to turn off correlations acco
317. r the selected forecast or assumption without a dialog CB FormatPrefs Sets format preferences for the selected forecast using a dialog 146 Crystal Ball Macro Calls CB Freeze This subroutine displays a dialog so you can select which assumptions decision variables or forecasts will hold their worksheet values during simulations Note Before calling this subroutine activate a worksheet and reset the simulation CB Freeze Example This example activates Futura with OptQuest xls resets any previously run simulation and opens the Freeze dialog Workbooks Futura with OptQuest xls Worksheets Model Activate CB ResetND CB Freeze CB Freeze Related Calls Name Description CB FreezeND Defines which assumptions decision variables or forecasts will hold their worksheet values during a simulation without using a dialog CB Reset Resets a simulation after prompting CB ResetND Resets a simulation without confirmation CB FreezeND This subroutine defines which assumptions decision variables or forecasts will hold their worksheet values during a simulation Tip Before calling this subroutine activate a worksheet and reset the simulation You must have at least one assumption decision variable or forecast in the list of cells to freeze or enable Otherwise CB MacroResult returns an error To freeze cells build a list of cells to be frozen and then use the cbFrzSetList constant to
318. rBadAssumption The parameters must agree with the specified distribution Ifthere is a problem with a parameter CB MacroResult returns cbErrBadAssumption Note Calling this function is not the same thing as entering an external assumption function such as CB Normal into a worksheet cell External assumptions are actual functions that return values using normal Microsoft Excel syntax but you cannot correlate them with other assumptions nor do they appear in any reports or sensitivity analyses Calling this function CB DefineAssumND is equivalent to selecting Define then Define Assumption CB DefineAssumND Example 1 This example defines a uniformly distributed assumption with a minimum value of 30 a maximum value of 40 and names it Number Of Units This example assumes you have already selected a single cell CB DefineAssumND cbDfaUniform 30 40 Number of Units CB DefineAssumND Example 2 This example defines a normally distributed assumption with the following characteristics and places it in the currently selected cell e A mean of 15 000 e A standard deviation of 1000 e The third parameter left blank since the normal distribution only uses two parameters e A lower truncation point defined by the value in cell B50 e An upper truncation point of 16 100 e A title of Expenses CB DefineAssumND cbDfaNormal 15000 1000 B50 16100 Expenses Defining Custom Distributions To define a custom distribution your macro c
319. rameters can improve accuracy Table 156 CB LockFitParm Parameters with Values VBA Data Parameter Type Value Description Dist Integer See Table 55 for constant Specifies the distribution with parameters to lock The following equivalents to the distributions from Table 55 can be used distributions listed in the following table cell under e Gamma distribution Location Shape parameters Description e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter Use Boolean True or False Indicates if the lock value should be used or not if set to True the lock value is used ParameterIndex Integer See Table 55 to determine The index of the distribution parameter to lock taken from Table 55 Optional index values for target parameters CB LockFitParm 191 VBA Data Parameter Type Value Description Value Double A positive real number The actual value to be used for the specified parameter Cell references cannot be used here To clear the locked value pass the constant cbParmUndefined Locked values are stored as if you had set them using Crystal Ball dialogs They do not need to be called before every CB Fit call CB LockFitParm Example The following macro statements define a variable named R
320. ramework To access the OptQuest Developer Kit you must reference the COM object named CBCOMDevkKit which is registered on your computer during the installation Development Resources In addition to this book the OptQuest Developer Kit contains two other files with information about kit contents and how to use it CB Com Devkit chm and OptDevKitRuntimeSample xls CB Com Devkit chm This help file is a reference with lists and descriptions of methods and properties in OptQuest Developer Kit classes It is located in the Docs folder beneath the main Crystal Ball installation folder by default C Program Files Oracle Crystal Ball Docs You can open and use CB Com Devkit chm directly from that folder at any time When you first open CB Com Devkit chm three namespaces appear in the navigation pane Figure 2 These namespaces are only used in C code not Visual Basic VBA code However if you are using VBA they indicate which classes are used for OptQuest automation Optimization and which are used for Predictor Predictor When writing VBA code you omit Optimization or Predictor as shown in the code examples included in this Developer s Guide 282 Using the OptQuest Developer Kit Figure 2 CB Com Devkit chm with Three C Namespaces E CB Com Devkit x El c s Hide Locate Back Forward Stop Contents Index Search E Decisioneering CB CBCOMDevKt Namespace E Decisioneering CB CBCOMDevKtt Optimization Namespace
321. rates assumption cells for all open workbooks CB GetAssum Retrieves information for a specific assumption cell CB GetForePercent Returns percentiles for forecast cells CB GetAssumPercent 153 CB GetAssumStat This function calculates the specified statistic for the assumption in the specified cell You can call this function from either a macro or a worksheet Note To call this function from a worksheet use the name CB GetAssumStatEN Table 93 CB GetAssumStat Returned Data Type Returned Value Returned Data Type The specified statistic for the assumption Variant Table 94 CB GetAssumStat Parameters VBA Data Parameter Type Value Description AssumReference Variant In a macro Range B3 In a Points to the assumption cell for which you want the statistic worksheet B3 Index Integer See Table 136 Calculates the specified statistic for the assumption in the specified cell using the values listed in Table 136 Theoretical Boolean True or False Indicates whether to return theoretical statistics True or Optional simulation empirical statistics False or no parameter entry Note If Theoretical is set to False or is not included CB GetAssumStat returns 0 unless you run a simulation before calling the function If Theoretical is set to True theoretical statistics are returned regardless of whether a simulation runs Use the following Index named constant and index values Table 136 t
322. rd CB ResetND CB BatchFit CB BatchFit Related Calls Name Description CB BatchFitND Runs the Batch Fit tool without displaying dialogs CB GetBatchFitOption Returns current settings for the Batch Fit tool CB BatchFitND Subtopics e CB BatchFitND Example 1 e CB BatchFitND Example 2 e CB BatchFitND Related Calls The Batch Fit tool helps you define assumptions when you have historical data for a number of variables The tool automatically selects which probability distribution binomial normal triangular uniform and so on best fits each series of historical data and provides you with the parameters to use in your model Batch Fit can also provide a table of goodness of fit statistics and a correlation matrix calculated between the historical data This call runs the Batch Fit tool and displays results without using a dialog Note Before calling CB BatchFitND reset the Crystal Ball simulation Table 9 CB BatchFitND Parameters Parameter Required VBA Data Type Table Index Required Integer Table 10 Value1 Optional Variant Table 11 Value2 Optional Variant Table 12 Value3 Optional Variant Table 13 CB BatchFitND 55 Parameter Value4 Required Optional VBA Data Type Table Variant Table 10 CB BatchFitND Index Parameter Required Integer Index Named Constant Value Value Description cbBft
323. rding to Value1 cbRunMinimizeHost 26 Sets whether to minimize Microsoft Excel during simulations according to Valuel Note This constant only applies in Normal and Demo speeds it does not apply in Extreme speed cbRunMinimizeSheets 27 Sets whether to minimize worksheets during simulations according to Value2 Note This constant only applies in Normal and Demo speeds it does not apply in Extreme speed cbRunHideForecasts 28 Sets whether to suppress forecast and assumption windows during simulations as well as overlay trend and sensitivity charts according to Value1 cbRunMode 29 Sets whether to run in Extreme Normal or Demo speed according to Value1 note that Extreme speed requires an Crystal Ball Decision Optimizer license cbRunRandomSeed 31 Specifies the initial random seed value according to va1ue1 cbRunPrecisionControl 40 Sets whether to stop a simulation when the forecast precision reaches a set confidence level only takes effect after a reset cbRunPrecisionConfidence 46 Sets the confidence level for precision control to va1ue1 cbRunReversePercentiles 47 Changes the interpretation of percentiles according to Value1 cbRunFormatPercentiles 48 Indicates how to format percentiles according to Value1 cbRunSaveAssumptionValues 49 Indicates whether to store assumption values for later analysis such as sensitivity analysis according to va1ue1 cbRunLeaveOpenOnReset 50 Sets whetherto leave the Crystal Ball Control Panel open when a
324. rements for Use bee or ghee TEE TE 278 Opt juss Developer Kit Batasspate x s4cadcn dv 279 Important OptOwuest Glasses cri ote AAA 2 9 Developing Optimization Code er ee 282 Development PAV aiia aee TEE HOO CERUOPHEY AE RA AAA EE 282 Devclopment A gd qud qq 282 Coding an Optimization ee ee dba qq ee eee 285 User defined Event Macros for Optimizations hes weed ee ee das eod 287 User defined Event Macro Nameg aus cess DR CREER HE RADEON ROG ORE RC AR RR 287 Using Events in VBA C 288 Event Signatures ras Te is 289 Constan and MICOS eaaa E a aa ae e el EOE e cade AEA EET SENEE ETETA TEET 291 Appendix B Using the Predictor Developer Kit o oooooooooooooooooooo 293 About the Predictoe Developer EX sitiada ra AA AAA do eaves TT 299 Who Should Use This Kit 152 asit perra Seed oo b eos 294 Lj 46 1043 0 7 em nnm 294 Contents xvii Developer Kit Use atid SIFUGIIES usse mre xx Re nentet RIERA 294 Specihic Requirements Tor Use ropero AAA 294 Predictor Developer Kit Namea cari AAA 295 Important Predictor Classes oir RS 295 Developing Time Seties Forecasting Code 1 ssoasauuee aua an rh REX RS 298 ee ee A ENANA eee ee AAA 299 xviii Contents Documentation Accessibility For information about Oracle s commitment to accessibility visit the Oracle Acc
325. rences e PredResults PredResultsWindow e PredResults PredSeriesResult PredResults This is the top level interface class that provides access to objects that retrieve results available through the Predictor results form This class has properties to access results preferences and to select series and methods This class has a method to paste the forecast results to your model PredResults PredResultsPreferences This class provides access to results preferences such as confidence intervals number of periods to forecast and Predictor results window display options PredResults PredResultsWindow This class provides access to the Predictor results window and enables you to set items such as selected series and method This class enables you to control the Predictor results dialog and access all of the controls on the form PredResults PredSeriesResult This class provides access to per series result information This class provides access to information such as series name best fit method forecast adjustments result statistics series historical data values and forecast data values An enumerator property of the PredResults class Series enables you to access each series by index into the input data range Developer Kit Use and Structure 297 Developing Time Series Forecasting Code For development with the Predictor Developer Kit you can use any development environment that supports the use of Microsoft COM components Such an en
326. rences density setting cbExtIncludeCellLoc True or False True includes cell location information False does not include cell location information cbExtIncludeLabels True or False True includes labels False does not include labels 134 Crystal Ball Macro Calls Index Index Parameter Named Constant Parameter Value Parameter Value Index Value Values to Use Description cbExtAutoFormat 10 True or False True applies formatting to the cells as appropriate False does not apply formatting cbExtSheetName 11 A string value The name of the sheet where extracted data is placed The representing a sheet name must follow appropriate sheet naming sheet name restrictions cbExtStartCell 12 A string value Specifies the first upper left cell of the extracted data representing a starting cell location cbExtStartSheet 13 See Table 74 Indicates where to extract the data described in Table 74 1 cbExtNewWorkbook 2 cbExtCurrentWorkbook_ NewSheet 3 cbExtCurrentWorkbook_CurrentSheet Note Calling ExtractDataND with this value will overwrite any settings through cbExtExistingSheet cbExtDataOptimizerType 14 See Table 75 Indicates which OptQuest data to extract following an optimization run If not explicitly set the current settings from the Extract Data dialog are used cbExtChooseDecVar 15 See Table 76 Indicates which decision variable data to extract following an optimizat
327. represent Assum1 uses asm2Address to represent Assum2 uses corrValue to represent Value and then uses a loop to stop execution when all correlated assumptions have been located As it runs it produces a list of the first and second assumption in each pair of correlated assumptions followed by the correlation value for that pair Sub EnumCorr2 CB CheckData Dim asmlAddress As String Dim asm2Address As String Dim corrValue As Variant Dim count As Variant Dim initialCount As Variant initialCount CB EnumCorrelation asmlAddress asm2Address corrValue count initialCount While count gt 0 Cells initialCount count 1 5 asmlAddress Cells initialCount count 1 6 asm2Address Cells initialCount count 1 7 corrValue count CB EnumCorrelation asmlAddress asm2Address corrValue Wend End Sub CB EnumCorrelation Related Calls Name Description CB EnumAssum Enumerates assumption cells for all open workbooks CB GetAssum Retrieves information for a specific assumption cell CB EnumDecVar This function enumerates decision variable cells for all open workbooks This command is useful for determining what decision variables have been defined for the open worksheets You can then call CB GetDecVar for each decision variable to retrieve specific information for example range minimum or maximum Table 66 CB EnumDecVar Returned Data Type Returned Value Returned Data Type The absolu
328. reset the simulation CB ResetND Example This example clears any simulation data and closes all forecast windows and charts without prompting to confirm the closures CB ResetND CB ResetND Related Calls Name Description CB Reset Resets a simulation after prompting CB Simulation Runs a simulation for specified number of iterations CB RestoreResults This subroutine opens the Restore Results dialog so you can restore previously saved simulation results any results data and charts created but not necessarily open at the time the results are saved You can restore any number of results files at one time but they must be opened one at a time by calling them with CB RestoreResults You do not need to reset the current simulation before you run this subroutine You can restore results while a simulation is running completed or stopped To run this subroutine you must have a saved cbr file or CB MacroResult returns cbErrRestoreResult CB RestoreResults is similar to CB RestoreRun available in Crystal Ball 2000 5 5 5 However CB RestoreRun and CB RestoreRunND restored an entire simulation saved with CB SaveRun or CB SaveRunND not just the results The existing simulation had to be reset before the saved simulation could be loaded and only one simulation could be restored at a time See the Oracle Crystal Ball User s Guide for more information on saving simulation results 202 Crystal Ball Macro Cal
329. rmatted cbBftOutputCorrelationMatrix 14 Used with va1ue1 to specify whether to output a matrix of correlations between the data series If set to True a matrix is produced cbBftLinkToCorrelationMatrix 16 Used with Value to specify whether to link to the matrix of correlations between the data series assuming cbBftOutputCorrelationMatrix 14 is set to True If set to True creates a link to the matrix cbBftOutputGoodnessOfFitReport 17 Used with Value1 to specify whether to output a goodness of fit report If set to True a report is produced Value2 can be used to supply a sheetname as a string cbBftOutputAssumReport 18 Used with Value to specify whether to output an assumptions report If set to True a report is produced Value2 can be used to supply a sheetname as a string cbBftOutputAssumFullStatistics 19 Used with va1ue1 to specify whether to include full statistics in assumptions reports If set to True full statistics and percentiles deciles are included Otherwise only parameter values and assumption charts appear cbBftRun 20 Runs the Batch Fit tool 56 Crystal Ball Macro Calls Index Named Constant Value Value Description cbBftUseDistLocking 21 Sets the Batch Fit tool to use parameter locking the same as checking Lock Parameters on the Fitting Options panel of the Batch Fit wizard cbBftOutputGoodnessOfFitAllStats 22 Used with Valuez to indicate that all statistics should appear when a goodness
330. rnal variables However ifan error occurs no dialogs appear Instead an error is returned by CB MacroResultDetail CB MacroResultDetail on page 194 Note If correlations are inconsistent CB CheckDataND returns CorrInconsistent Call CB CheckData or CB CheckDataND when modifying the structure of the worksheet or workbook which includes but is not limited to inserting and deleting rows columns and individual cells Other examples of when to use the CheckData calls include each time you start a new enumeration use a CB Get call that relies on cell references that might have changed and before using calls that extract data or create reports CB CheckDataND Example 1 This example runs a simulation of 500 trials initializes all the internal variables for the following enumeration and then enumerates all the forecasts opening each forecast chart Dim s As String Dim r As Range CB Simulation 500 CB CheckDataND S CB EnumFore CB CheckDataND 75 While s lt gt Set r Range s CB OpenFore s CB EnumFore t t 1 Wend CB CheckDataND Example 2 This example runs CB CheckDataND checks for errors and displays a message if one occurs Any following code runs if the error check is successful Sub ErrorHandling Check the data CB CheckDataND Check if CheckDataND failed If CB MacroResult lt gt 0 Then Notify user or log error MsgBox CB MacroResultDetail Msg Exit Sub End If Insert code tha
331. ro Calls Used With Specified Index Values of Index Named Constant or Other Value Value Description For Index 7 Integer cbValZeroBased 1 Uses zero based value axes normalizing the lowest forecast value to 0 This constant is included for compatibility with Crystal Ball 2000 x 5 x For Index 7 Integer cbValRelative 2 Uses relative value axes the actual minimum and maximum values For Index 7 Integer cbValMinMaxDiv 3 Uses value axes by setting a minimum Va1ue2 and a maximum Value3 so you can focus on a particular value range For Index 8 Integer Any integer between O and 100 n a Sets the first certainty band to display Use this with inclusive Value2 through Value7 Note cbTypCertCenteredOnMean 2 is now obsolete Table 208 following describes the Value2 parameter Table 208 CB TrendPrefsND Value2 Parameter Values Optional Variant Used With Specified Parameters and Values Value Description For Index 7 and Value1 3 Double Any number Defines the minimum value for the value axis For Index 8 Integer Any integer between O and 100 Sets a second certainty band to display Use this with inclusive Valuel Table 209 following describes the Value3 parameter Table 209 CB TrendPrefsND Value3 Parameter Values Optional Variant Used With Specified Parameters and Values Value Description For Index 7 and Value1 3 Double Any number Defines the max
332. rs VBA Data Parameter Type Value Description DistType Integer Integer value or Specifies a distribution type for the assumption The number of parameters named constant varies with the distribution type See the table on the next page for types See Table 55 and associated parameters Parmi Parm2 Variant See Table 55 Parameter values for the distribution type specified with the DistType Parm3 Allare parameter optional LowCutOff Variant Numeric Sets the lower truncation value The default is Infinity This parameter is Optional ignored for custom distributions HighCutOff Variant Numeric Sets the upper truncation value The default is Infinity This parameter is Optional ignored for custom distributions NameOf Optional Variant Title surrounded by Names the assumption If you do not specify a name Crystal Ball uses the quotes first of either the cell s range name text from the cell preceding to the left of that cell text from the cell one row before above that cell or the cell s coordinates Dynamic Optional Variant True or False Specifies whether Crystal Ball calculates cell parameters once at the beginning of the simulation or with each trial Parm4 Optional Variant See Table 55 The minimum value for the 4 parameter beta distribution CB DefineAssumND 113 Note The optional Dynamic parameter is deprecated in this release It remains in the code for compatibility with 2000 5 5 5 ve
333. rsion ID number CB IsCBObject This function determines if a worksheet or workbook contains Crystal Ball data Table 153 CB IsCBObject Returned Data Type Returned Value Returned Data Type Whether the current worksheet or workbook contains Crystal Ball data Boolean Most of the Developer Kit subroutines and function will not work if the active worksheet or workbook does not contain Crystal Ball data CB IsCBObject 189 Table 154 CB IsCBObject Parameters Parameter VBA Data Type Value Description AnObject Variant A Microsoft Excel workbook or worksheet For Points to the worksheet or workbook to check for example Worksheet Sheet1 Crystal Ball data CB IsCBObject Example This example checks to see whether user sheet is a worksheet object and not a module sheet or something else If it is a worksheet it checks the worksheet and its parent the workbook for Crystal Ball data If user sheet is not a worksheet or if no Crystal Ball data exist on either the worksheet or the workbook it displays an error message and exits the macro Otherwise it continues Set user sheet Worksheets Sheet2 If Not TypeName user sheet Worksheet Or _ Not CB IsCBObject user sheet Or _ CB IsCBObject user sheet Parent Then MsgBox Active document does not contain Crystal Ball Data Exit Sub End If CB IsCBObject Related Calls Name Description CB MacroResult Tells you if a Crysta
334. rsions of the Crystal Ball Developer Kit but will be obsolete in later versions because cell references are always dynamic in later versions of Crystal Ball Beginning with version 11 1 1 0 00 the lognormal distribution has three parameters instead of two If this call is used in a model that was created in an earlier version of Crystal Ball the third parameter has a value of 0 The following table lists the values for Parm1 Parm2 Parm3 and Parm4 for each DistType constant For more information about these parameter values see the description of each distribution type in Appendix A of the current Oracle Crystal Ball User s Guide The current Oracle Crystal Ball Statistical Guide lists defaults for each parameter value Table 55 CB DefineAssumND Parameter Values and Descriptions DistType Parameter Named DistType Parm4 Constant Value C continuous Parameter Parm3 Description D discrete Index Value Parm1 Description Parm2 Description Description Optional cbDfaNormal C 0 mean value standard deviation n a n a value cbDfaTriangular C 1 minimum value likeliest value maximum value n a cbDfaPoisson D 2 rate value between n a n a n a 0 and 1000 cbDfaBinomial D 3 probability trials a whole number n a n a between O and 1 greater than O and less than 1000 cbDfaLogNormal C 4 mean value standard deviation location n a value cbDfaUniform C 5 minimum value maximum value n a n a cbDfaEx
335. rt messages to show and to reset message display preferences and can be returned by CB GetRunPrefs e Constant cbRunAssumeZerosForUnspecifiedCorrs 65 is added in 11 1 2 3 500 CB GetVersion CB GetWorksheetVersion e Starting with version 11 1 1 0 00 two optional parameters ValueType and Index return the full or partial version ID or build number Full IDs or numbers are returned as strings and partial IDs or numbers are returned as an integer CB IsCBObject e The parameter SheetObj changes to AnObject its data type changes from Object to Variant CB OpenSensitiv e Achart can now be explicitly selected via CB EnumChart and CB SelectChart before it can be opened CB OpenTrend e Achart can now be explicitly selected via CB EnumChart and CB SelectChart before it can be opened CB PasteData e This subroutine no longer pastes from Crystal Ball s internal clipboard Instead it pastes all Crystal Ball data currently existing within the range specified by CB CopyData or CB CopyDataND to the extent that appropriate value or formula cells exist within the range selected for pasting For best results use this subroutine immediately after CB CopyData or CB CopyDataND Changes to Existing Calls 267 CB RunPrefsND e The following Index constants used in Crystal Ball 2000 5 have changed as indicated O O O O cbRunBurstMode 5 obsolete and removed from the code cbRunResetToOriginal 6 obsolete and removed from
336. rystal Ball 2000 5 5 5 compatibility and is replaced by cbDfaMinExtreme and cbDfaMaxExtreme in later versions of Crystal Ball Beginning with version 11 1 1 0 00 the lognormal distribution has three parameters instead of two If this call is used in a model that was created in an earlier version of Crystal Ball the third parameter has a value of 0 The following table shows Criterion parameter values used to specify which fitting statistics to return Table 80 CB Fit Criterion Parameter Values Required Integer Named Constant Value Index Value Description cbFitChiSquare 1 Returns the chi square statistic cbFitChiSquareP 2 Returns the chi square statistic p value CB Fit 141 Named Constant Value Index Value Description cbFitKolmogorovSmirnov 3 Returns the Kolmogorov Smirnov statistic cbFitAndersonDarling 4 Returns the Anderson Darling statistic cbDfaAutoSelectRanking Method 5 Automatically selects a ranking method depending on characteristics of the data CB Fit Example 1 This example selects a range of data in column D and then calls CB Fit in a For loop The loop fits the triangular distribution to the range of data and prints the results of each possible test to the spreadsheet next to the original data in cells E4 to E7 CB SetFitRange Range D4 D104 For i 1 to 4 Range E3 Offset i Value CB Fit cbDfaTriangular i Next i CB Fit Example 2 This example selects a range
337. rystal Ball while leaving Microsoft Excel open CB StopMultiSimul This subroutine more effectively uses resources when running multiple simulations with CB Simulation Call CB StartMultiSimul before multiple simulations and then call CB StopMultiSimul after the simulations are run See the example for CB StartMultiSimul CB StopMultiSimul Related Calls Name Description CB Simulation Runs a simulation CB StartMultiSimul Marks the start of multiple simulations 242 Crystal Ball Macro Calls CB TrendPrefs Opens the Trend Preferences dialog for the selected trend chart either open or closed If more than one trend chart is found opens a chooser dialog If no trend chart has been defined this call creates a new chart with no associated forecast using the default preferences This chart then becomes the selected chart for subsequent trend chart calls A simulation must be run before this call is used CB TrendPrefs Example This example runs a simulation either creates a trend chart selects a single trend chart or opens a chooser dialog if there are multiple trend charts and then opens the Trend Preferences dialog for the selected trend chart CB Simulation 1000 CB TrendPrefs CB TrendPrefs Related Calls Name Description CB TrendPrefsND Sets preferences for the specified trend chart without using a dialog CB TrendPrefsND The function sets preferences for the selected trend chart If mor
338. s 139 CB EST Exanpled ici id A rs NONE CD ExteactData ND Related Calli aclarar aa 139 CBRE serios ee bas d esi vas dd Pa Sees aoa ad s 139 CERTEGE reska del quon der qox pub qe rop Ede RI eee e oe bi 142 CETERAE Su cei oars TIR ices EAM eens ones cess Xd QE S ees 142 CDLPIEEXSIOPIEO 420046200 pSaxeeqQepedebeqePIP Pede qadqdP qe qaid 142 CB Fit Example 4 reddes errr eT Te Tee EE 143 iar d i pec AAA 144 SO POPES conan nnd sdb kak EORR CRUEL AMEN RO AU o RC 144 CB FormatPrefs Example ee ee dd 144 LE FormatPreis Related Calle 4Liauckaa deck ek e de qoe td ek doe Edo bait 144 LB Perens to iue A pev che bus ad pex aq ird 145 CB FormatPreND Examplel 122122244 xasthas uah o dudaub Rad REA RS 146 CB FormatPrefsND Example2 bas 146 CR Pune D Rhed DUE eae eed Wed awe od Kex AMA 146 LB POSEE Lu sera Rab Rao E o d RE AED A GO RE ACRIOR DRE OR UR 147 CB Freeze Example ad Beet eRe as ere ee 147 LE ts DOLOS DAE aar dde grep d Jer Ele qb de oae e den ER de ol ded pode d 147 CATE qe ros o a o io a a leu 147 CE PreeseND ESB veras par praia 148 GB Dese NI Rda ES 4a dados coe dew oe qoo Pe Ae eR ee AS 149 CB GetAsmSensitivityChartGroup ass dad 149 CB GetAsmSensitivityChartGroup Example 2222242 serrke reges 150 CB GetAsmSensitivityChartGroup Related Call 0 0 ee eee eee ee 150 CB GetAssum
339. s 164 ai ODE i easier a ie Een Ceci eot bsc bed Med da 166 UB GADE nc ur e i RUE UHR El v UHR Held a rd Pcr bd i HEC Vd DR GU ERU RR QR 168 CB GetExecel2 OD 7 FOREIGN OG uad ronin dandas demand bdo ic uid niai P lad uice Da dd dd 169 CB GetFitFilter in dia ais Daisies aos gus deta iii Jia dida 170 Crystal Ball Macro Calls CB GetFitParm RR nachos uda E sided m Nn S Fe A cid dug ma S dh at due arate Dali mr ALIE GS e no NOE CORNER TC TO Cr EI GEG IZ cr me M A Hoccidapebcoda Foren eb aad koociadd A PSU CB Ger R RPEEfS eo aieo den d peocod Fora bebo donc vdd poco Finca bebe aa BOE Hoe een ERI ODON carr RN VOR CB GatIwoDS mulato OPIO E E 184 CB GetVersion 187 CE re LPO OS q Di a ERU GU CRETE zn casita tes os a cur Lane CRIAS ict ac gue tacite tas ee e OD CE Doc RP STRE arun Gendt Doc RUE GC DUE PS S ET uini o RUE CB Macro Resi aon eor ni dta i dl E T E 192 o A AN 194 CB OpenChart RU uA A L E I A LE O A E A N EE A AT E d eeno o A TEM UI CB OpenSensitiv ooccccoccncoocnononnncnnnnns TTE ERR 198 CB OpenTrend eesseees PENERE EELT PENEIRA PEPESE PEFEA A ee CA Paste Datini ea nanag ganah PEE E ETETETT ET 199 Graco M TD ES A 201 cc M M AN EEE veu A io Gates 201 GB CARO ete CUS a a Ra Gad dat A GB REEERE SUND eis ue
340. s 17 DB Ge Vert MA re T CB GetVersion Example ET qaad E d Te f dc dora Rb M RR cd dba ok aae QE CB GetVersion Related Calls ee 188 Ret ee nee Laos us Eas rc is pad PEE 188 CB GetWorksheetVersion Example 4552252242222 9 pa deb RA REad Oa ege 189 CB GetWorksheetVersion Related Calls bes 25 du TR RSS ew 189 LIED open 18d RR I E Fa ERO a RR PE a ER dod acid A EE Rs 189 CB IsCBObject Example rmn i 190 CP IsCBObject Related Calls voor ri RR Ra Rer exe VS UU ril Po ccm NI OED Jm 190 CB Iterations Example2 diaria rra data 191 CB Iterations Related Call er TS eer iyd sites TY piei lt 191 A AA a HORS E HR KU EA UO es IL CB LockFitParm Ae MA ses 5 CB LockFitParm Related Calls ads Rs Rd bas vas ad a 192 OO c3 kg det order doe dpa E A qe E de Eo de qo OR OR CE e E eo oboe eee LE i Ero i25 7 emm 193 CB MacroBesult Related Gallo corras rra drid re 194 CB MacroResultDetail uS or beg aa ed Eque bus powi 194 CH MadoResuDeul EseUmpmls 4224 64A a a REER s 05 495 CH MacioBesaliDebul Related Call Laia 196 CB OpenChart er bd xad M 196 A M icu a RS Staats atte T d avt st Pee a p o PR CP Opent EIA rara wer sone Euaxexdqe ized een 197 CB OpenChart Related LA 2asadaseszectizesezraesedetoceshbmadQ Idwed qe 197 CB OpenFore T er TET r or er ux T ass er lt 197 CB O
341. s oid quie Mpix SN Ed ES dide EE dl LB Lieaten IND adri teas m essa DE DS HP SI edunt OS 101 A Tm 102 sr yp M 106 UBDecstonTableD comarca ten o Hc exe Ger eek dined han eee 106 CBDenneAT PANS emir cds lr ads algas no CO DEIA Sora ica dare ES DeimedssuTWIWD ost Like BIEN A cdo Saa 117 EM a apa nea ea 119 DE DOME ta siden A AS 120 CB DANG FONG a a A A A Oud or ERE UR UR 123 CB DTM ETE NN D o a ar iii kiss ese CB DeleteChart sso ata A nian asidiGon ated E E A aaabudonaks 127 AA O M dU 128 ESE Ao 130 CE o 131 A A 133 EIA DD A A E 133 A teli aenea nde eg Santee E AA Miedo tuse clue En EE 139 SE EMRE FERS cna sana areata a Ded Quat EAR tanta BEP EUER Had dca an Gila 144 CAM FERC OUD a cao ada dne pU D rua adn A nad dra cado Gia 145 CB FE me 147 8 Precz A CB GetAsmSensitivityChartGroup sosesc mie 149 CB GetAssum A PE e eee T ioo etin CMM Mis p melted a A AS A EN 154 A CE 155 o A A 158 e A abasuitg qudaundd mhaumiens caneueds miacaitag pd ptg Cui REPRE 160 e aeni otacuteg qiu nde nintedisanddnads uiauanis suse udo mises nM Medi ius ve lO REDI plu e NET a ES Gor ogelguof BVP Liu csesn recs nner ip n KEEPER LOS CO AAA OI O bac ad edu i ean xd CL E OED Ga
342. s signature parameters or arguments are defined as follows 290 Using the OptQuest Developer Kit e TestValue The Efficient Frontier test value just completed Note Note Returning anything other than a zero from a macro will stop the optimization Constraints and Macros You can set up an OptQuest constraint in the form A1 lt 100 or simular and use CBBeforeSimulation or CBBeforelteration to modify cell A1 If you do this a constant constraint warning appears and warns you that one or more constraints do not appear to contain decision variables that they are marked as constants and therefore no feasible solutions may be found This warning only applies if you don t have a macro that modifies the cell If you are using a macro to change values in the referenced cell you can close the warning and continue with the optimization Then the constraint will work as intended If you check the Do not show box you won t need to respond to the message again while you are using that particular model Global Macros If you want to run certain event macros with any or all of your Crystal Ball Decision Optimizer models you need to make sure that the workbook containing those event macros is open in Microsoft Excel User defined Event Macros for Optimizations 291 292 Using the OptQuest Developer Kit Using the Predictor Developer Kit In This Appendix About the Predictor Developer a ai alias 293 Developer Kit Se and
343. s the assumption in cell B7 and defines a triangular distribution using the 25th percentile the likeliest value and the 75th percentile CB DefineAssumND receives this information about the distribution and parameter set and defines the assumption s distribution with a 25th percentile value of 5 a likeliest value of 10 and a 75th percentile value of 15 Note Ifyou use the numeric value of the index instead of the constant name for cbParmPercentile as in Example 3 you must use the sample syntax 0 percentile so that the function can identify the parameter by the numeric value Range B7 Select Valuel CB DefineAltParms cbDfaTriangular 0 25 10 O 75 CB DefineAssumND Valuel 5 10 15 CB DefineAltParms 111 CB DefineAltParms Related Calls Name Description CB DefineAssumND Defines or changes the assumption in the selected cell CB GetAssum Retrieves information for a specific assumption cell CB SetAssum Changes certain attributes for the assumption in a cell CB DefineAssum This subroutine opens either the Distribution Gallery to define new assumptions or the existing distribution dialogs to change existing assumptions in the selected cell The selected cell must be a blank cell or a simple value cell You cannot define an assumption in a cell with a formula a cell reference or text If a simulation runs before this subroutine is used the simulation must be reset before the assumption is defined
344. s uade sue deer bres prd hr EeQaerbr ia 250 CB WorksheetProtection S lese Siki dus E sea piu i CH WeksheePtoectan Exunpnbl 2 isi ad seed eddie cedeekonewdaadecen E CB WorksheetProtection Example 3 coca D CR UR KORR EO ORE AUR EA RE 292 Chapter 4 Changes from Previous Versions 0 0 000 RII RII 253 o rada RE videram O oder e ios A ut ui M 253 Added in Crystal Ball 11 1 x e pd 252 Added sa Cera Bal he s AAA ESA 254 Not Included in This Version MMgkt adobe ke Rese qid qud iud 256 Changes to Existing Calls Sias T 224 aw seus 257 CUASI daa TN CB AutoDownshift not A E A ie 258 Pepe LY air AAA 238 CB CellPrefsND e Kad ore us VT Pad T er Koad ete T 258 CIC Bae REIN La Suse pacti ga eee M RW coq qr dg AA Rat ey eee Pac gar e 259 CPCS pra rada AAA 259 CB ClearData RT eee re PE er TRAE ee eee ee 259 5 AA SR i E DS ewes 209 CB Closebore sois a dee ieee ila EE NER EE T E ETT 259 CB CloseSensitiv Edd E opa s d dated d doi a DO RUE dn bab T 259 COCINE AS es eya pr a hee eae qr beeen bi AR CBLoprDabeand CBLLODPDAND Lussaxeq xukirbbbu kh APA RR RC 259 Contents xv xvi Contents CB CorrelateND S TER NUM eae Ce EEE ENTAS TT 260 CBE ortelste NIS TNI Laon aces aoo EE du CHER eb Eo Rp 4 a ae 260 CU CIR id rapaces qd tidad ici 260 CB CreateBptND 22 6255 M 260 Benne
345. sND Sets chart preferences for the selected forecast or assumption without a dialog CB FormatPrefsND Sets format preferences for the selected forecast without a dialog 144 Crystal Ball Macro Calls CB FormatPrefsND This subroutine sets format preferences for the forecast corresponding to the selected cell without using the Chart Preferences dialog The defaults are the current settings on the Axis tab of the Chart Preferences dialog Select a forecast cell before calling this subroutine to change the format preferences for a single forecast If you call this subroutine to change a single forecast chart A11 is False when no forecast cell is selected CB MacroResult returns cbErrNoForecastInCell See the Oracle Crystal Ball User s Guide for more information on how to format forecast charts Table 81 CB FormatPrefsND Parameters VBA Data Parameter Type Value Description Index Integer See Table 82 for Specifies which forecast chart Axis preference to change Values appear in values Table 82 1 cbFmtFormatType 2 cbFmtUnderlying 3 cbFmtCommas 4 cbFmtDecimalPlace Value Variant See Table 83 for Used with the Index parameter to specify forecast chart Axis preference values settings Values appear in Table 83 A11 Optional Variant True or False True applies this option to all forecasts False applies this option only to the selected forecast The default is False The Index parameter Table 82 on p
346. sNone 1 Includes no methods cbPredictorMethodsAll 2 Includes all methods cbPredictorMethods1Best 3 Includes the method with the best accuracy cbPredictorMethods2Best 4 Includes the method with the second best accuracy cbPredictorMethods3Best 5 Includes the method with the third best accuracy Use cbRptOK to generate the report after you use the other index values to set report preferences A simulation must not be in progress If a simulation has not yet run the report only includes assumption information Note To add individual charts use constants cbRptChooseOverlay cbRptChooseTrend and cbRptChooseSensitivity from Table 32 Use these constants with CB SelectChart and the constants in Table 40 If you create a chart through the Developer Kit open it before including it in a report Otherwise the chart will show up in the report with a no data available message See the Oracle Crystal Ball User s Guide for more information on creating reports CB CreateRptND Example 1 This example runs a simulation so that the report can have forecast and charts in it Then it defines the report type as Custom sets preferences not to include a trend chart an overlay chart or any assumption information It does include forecast charts for all the forecasts but no other forecast statistics or information The charts are in Microsoft Excel format When you use a ClearList constant it clears all individually selected items of that type
347. sage when an obsolete call or constant attempts to run False switches off this alert The default is True CB AlertOnObsolete Example This example switches off alerts when obsolete macro calls arguments and functions are used CB AlertOnObsolete False CB AlertOnObsolete Related Calls Name Description CB AlertOnArgumentError Displays a message when an argument error occurs CB AlertOnMacroResultError Displays a message when an execution error occurs 52 Crystal Ball Macro Calls CB AssumPrefsND This subroutine sets attributes of Crystal Ball assumptions without using the Preferences menu on the Define Assumption dialog The default for any preference is the previous setting in the interface Different from Crystal Ball 2000 5 5 5 this subroutine is used to change preferences for individual assumptions instead of all assumptions You must select a single cell with an assumption before using this subroutine If the selected cell does not contain an assumption a cbErrNoAssumptionInCell error appears Table 6 CB AssumPrefsND Parameters Named Constant or Boolean Parameter VBA Data Type Value Index Value Description PrefItem Integer cbAssumShowCDF 1 Sets whether to display the distribution as a PDF False or CDF True PrefItem Integer cbAssumShowMean 3 Sets whether to display the mean line on the distribution dialog True OnOff Boolean True or False n a True turns on the option
348. scription CB CloseSensitiv Closes the selected sensitivity chart CB CopySensitiv Copies the selected sensitivity chart to the clipboard CB EnumChart Returns the unique name of the next chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB OpenTrend This call opens the selected trend chart If no trend charts have been created for a model one is created It is blank until one or more forecasts are added with the appropriate CB TrendPrefsND call If more than one chart is found but one is not selected a chooser dialog appears Note This call is included for compatibility with Crystal Ball 2000 x 5 x However it differs somewhat from earlier versions For details see CB OpenTrend on page 267 To open a chart of a specific type by its chart ID use CB OpenChart CB OpenChart on page 196 CB OpenTrend Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next trend chart in the workbook and then opens it CB Simulation 1000 CB CheckData CB SelectChart cbChtTrend CB EnumChart cbChtTrend CB OpenTrend CB OpenTrend Related Calls Name Description CB CloseTrend Closes the selected trend chart CB EnumChart Returns the unique name of the next chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB PasteData This subroutine pastes assumptio
349. seTrend Related Calls This call closes the selected trend chart If more than one chart is found but one is not selected a chooser dialog appears Note This call is included for compatibility with Crystal Ball 2000 x 5 x However it differs somewhat from earlier versions For details see CB CloseTrend on page 259 To close a chart of a specific type by its chart ID use CB CloseChart CB CloseChart on page 79 CB CloseTrend Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next trend chart in the workbook and then closes it CB Simulation 1000 CB CheckData CB SelectChart cbChtTrend CB EnumChart cbChtTrend CB CloseTrend CB CloseTrend Related Calls Name Description CB EnumChart Returns the unique name of the next chart of the specified type CB OpenTrend Opens the selected trend chart CB SelectChart Selects the chart with the specified chart ID CB CopyData Subtopics e CB CopyData Example e CB CopyData Related Calls This subroutine stores a selected range definition for later use by CB PasteData which pastes all current Crystal Ball data of the selected type or types from the range stored by CB CopyData You can use CB CopyData with CB PasteData to quickly set up rows or columns of forecasts assumptions with similar distribution types or decision variables with similar bounds The 82 Crystal Ball Macro Calls works
350. see Table 25 A11 Optional Variant True applies settings to all assumptions or forecasts False applies settings only to the selected assumption or forecast The default is False Note Optional parameters SeriesAxisIndex Value2 and Value3 are currently not supported The zndex parameter Table 24 works with the Va1ue parameter Table 25 to set basic forecast and assumption chart preferences Table 24 CB ChartPrefsND Index Parameter Values Required Integer Named Constant Value Index Value Description cbChtChartType 1 Sets the chart type according to the Value setting cbChtDistType 2 Sets the distribution type according to the Value setting cbChtGroups 3 Sets the grouping in the histogram according to the Value setting cbChtMeanLine 9 Turns on and off the mean line according to the value setting cbChtHorizGrids 6 Turns on and off horizontal grid lines according to the Value setting 72 Crystal Ball Macro Calls Note The following Index constant is obsolete in Crystal Ball 7 x and later including 11 x cbChtRedrawFrequency Index 4 The Value parameter Table 25 works with the Index parameter Table 24 to set forecast and assumption chart preferences Table 25 CB ChartPrefsND Value Parameter Values Required Variant Used With Specified Values of Named Constant or Index Index Boolean Value Value Description For Index 1 c
351. selected assumptions and is specified by a combination of the AssumSelectionType and AssumSelectionRange parameters If selected ranges do not contain an assumption in an existing matrix a new matrix is created If the selections contain only assumptions from one matrix it is updated If an assumption already occurs in another matrix CorrMatrixErrorAlreadyCorrelated is returned Table 29 CB CorrelateMatrixND Parameters VBA Data Parameter Type Value Description MatrixLocation Microsoft A multicell range Indicates where the matrix is defined must be a square range with Excel defined by the the same number of rows and columns Range upper left and lower right comer cells LowerTriangular Boolean True Or False Indicates orientation of correlations within the matrix range True places values in a triangle defined by the upper left the lower left and the lower right corners of the matrix while False places them in a triangle defined by the upper left upper right and lower right corners 88 Crystal Ball Macro Calls VBA Data Parameter Type Value Description AssumSelectionType Integer 0 4 as described The following values indicate how to select assumptions to correlate following or other actions 0 cbCorrMatrixDelete deletes the specified matrix 1 cbCorrMatrixAsmPicker cell ranges contiguous or discontiguous that contain the assumptions to use they must match MatrixLocation dimensions 2 cbCorrMatri
352. selected cell use cell Select first to select the cell cbTwoDGetAssum 2 Works with Va1ue1 to enumerate the list of assumptions by type uncertainty or variability returns a string containing the full name cell address of the cells Each successive call returns the next assumption in the list cbTwoDOuterSimfTrials 3 Returns the number of trials in the outer uncertainty simulation loop cbTwoDInnerSimTrials 4 Returns the number of trials in the inner variability simulation loop cbTwoDForeOption 5 Returns the va1ue1 constant that indicates the current setting for forecast chart window display options cbTwoDOutputOption 6 Used with Value to get output report options cbTwoDPercent 7 Used with Va1ue1 to return current percentile settings optionally you can supply a Microsoft Excel range to fill with percentile values cbTwoDMSDOption 8 Returns the maximum number of uncertainty simulations to display in the output report and overlay chart Table 147 CB GetTwoDSimulationOption Value1 Parameter Optional Integer Related Value For Index 2 cbTwoDGetAssum Integer Value or Named Constant Index Description cbTwoDGetUncertainty 1 Used with coTwoDGetAssum to enumerate the list of selected uncertainty assumptions For Index 2 cbTwoDGetAssum Integer cbTwoDGetVariability 2 Used with cbTwoDGetAssum to enumerate the list of selected variability assumptions For Index 3 coTwoDOuterSim Trials Positive whol
353. specify which individual charts to include in a report when charts are selected with CB SelectChart see Table 40 Table 40 For Index cbRptChooseChartype Value1 Values Optional Integer Named Constant Value Index Value Description cbChartAll 1 Includes all charts of the specified type cbChartOpen 2 Includes all open charts of the specified type 98 Crystal Ball Macro Calls Named Constant Value Index Value Description cbChartChosen 3 Includes chosen charts of the specified type cbChartAdd 4 Adds the selected chart to the list of chosen charts cbChartClearList 5 Clears the list of chosen charts With Index set to cbRptDefinedType you can indicate which predefined report type to use see Table 41 Table 41 For Index cbRptDefinedType Value1 Values Optional Integer Named Constant Value Index Value Description cbRptFull 1 Report format is the predefined full report cbRptAssumption 2 Report format is the predefined assumption report cbRptForecasts 3 Report format is the predefined forecast report cbRptDecVars 4 Report format is the predefined decision variable report cbRptindex 5 Report format is the predefined index report cbRptCustom 6 Report format is set through various CB CreateRptND code statements cbRptOptimizer 7 Report format is the predefined OptQuest report available following an OptQuest optimization run cbRptPredictor 8 Report format is the prede
354. st Developer Kit describes how to automate OptQuest optimizations See Appendix B Using the Predictor Developer Kit for information about automating and controlling Predictor forecasting Note The Predictor Developer Kit described in this Developer s Guide is completely rewritten Code written for CB Predictor in Crystal Ball versions earlier than 11 1 1 3 00 is not compatible with the current version of Predictor or this Predictor Developer Kit Who Should Use the Crystal Ball Developer Kit The Crystal Ball Developer Kit is appropriate for advanced users who want to automate repetitive spreadsheet analysis This manual assumes that readers are familiar with Visual Basic for Applications and Crystal Ball What You Will Need Crystal Ball runs on several versions of Microsoft Windows and Microsoft Excel For a complete list of required hardware and software see the Oracle Crystal Ball Installation and Licensing Guide How This Manual is Organized This manual contains descriptions of the Crystal Ball Developer Kit macro calls It also discusses the COM Developer Kit for OptQuest Predictor and Oracle Smart View for Office integration Each macro description includes a list of parameters and an example of the use of the relevant calls The manual includes the following additional chapters e Chapter 2 Crystal Ball Developer Kit Overview Describes how to use the Crystal Ball Developer Kit and contains an alphabetic
355. st xls Worksheets Model Activate Range C9 Select CB CloseFore 80 Crystal Ball Macro Calls CB CloseFore Related Calls Name Description CB OpenFore Opens forecast window for selected cell CB CloseSensitiv Subtopics e CB CloseSensitiv Example e CB CloseSensitiv Related Calls This call closes the selected sensitivity chart If more than one chart is found but one is not selected a chooser dialog appears Note This call is included for compatibility with Crystal Ball 2000 x 5 x However it differs somewhat from earlier versions For details see CB CloseSensitiv on page 259 To close a chart of a specific type by its chart ID use CB CloseChart CB CloseChart on page 79 CB CloseSensitiv Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next sensitivity chart in the workbook and then closes it CB Simulation 1000 CB CheckData CB SelectChart cbChtSensitiv CB EnumChart cbChtSensitiv CB CloseSensitiv CB CloseSensitiv Related Calls Name Description CB CopySensitiv Copies the selected sensitivity chart to the clipboard CB EnumChart Returns the unique name of the next chart of the specified type CB OpenSensitiv Opens the selected sensitivity chart CB SelectChart Selects the chart with the specified chart ID CB CloseSensitiv 81 CB CloseTrend Subtopics e CB CloseTrend Example e CB Clo
356. stributions cbParmLogMean 3 Log mean cbParmLogStDev 4 Log standard deviation cbParmGeoMean 5 Geometric mean cbParmGeoStDev 6 Geometric standard deviation cbParmMean 1 Mean cbParmStDev 8 Standard deviation cbParmMinimum 9 Minimum value cbParmLikeliest 10 Likeliest value cbParmMaximum 11 Maximum value cbParmLocation 12 Location parameter See Table 55 cbParmScale 13 Scale parameter See Table 55 cbParmMode 15 Mode cbParmAlpha 16 Alpha parameter See Table 55 cbParmBeta 17 Beta parameter See Table 55 cbParmShape 18 Shape parameter See Table 55 cbParmRate 19 Rate value See Table 55 cbParmMidpoint 20 Midpoint value See Table 55 cbParmDegFreedom 21 Degrees of freedom value See Table 55 cbParmPercentile 0 Percentile value Add the desired percentile to this parameter for example cbParmPercentile 80 indicates the 80th percentile Note Because there are three alternate parameter sets in addition to percentiles for the lognormal distribution the cbParmRegular named constant cannot be passed to CB DefineAltParms when setting up an alternate parameter set for the lognormal distribution You must explicitly set the parameter set with for example cbParmLogMean and cbParmLogStDev cbParmModeis included to support the extreme value distribution for backward compatibility with Crystal Ball 2000 x 5 x In later versions of Crystal Ball that distribution is replaced with the maximum
357. subroutine for example The next section describes new Crystal Ball Developer Kit calls In this version of the Crystal Ball Developer Kit all macro calls are listed together in alphabetical order in Chapter 3 For lists of macro calls grouped by functionality see Chapter 2 For information on how the Developer Kit calls have changed since the 2000 5 5 5 version see Chapter 4 Changes from Previous Versions Technical Support and More Oracle offers a variety of resources to help you use Crystal Ball such as technical support training and other services For information see http www oracle com crystalball Documentation Changes 23 24 Welcome Crystal Ball Developer Kit Overview In This Chapter MAI a ue p MT 25 How to Use the Crystal Ball Developer Kit 1 eicere enema hen enn 26 Alphabetic List of Crystal Ball Macro falls 23 tends ei ede ee 32 Spreadsheet Functions For Use in Microsoft Excel Models sese 38 Opening and Closing Cystal Ball cis patrias qaid all Va duced edd ties dad dedu eh 39 Seting Mp and Run MU ni 39 Controlling Crystal Ball Char WIDGONS ora aa 41 iur SPEI PREMO E TOILET 41 Handling Crystal Ball RESURS oxirini rara ei Ca BR CH a QU GER De A dU Gau ond 42 set ng and Getting Prefe tene arc e o Er aad dt ED roO t arde 43 A O E E EE AT 44 Special CAMS E E E A E dd E 44 Introduction This chapter tells how to use the Crystal Ball Developer Kit an
358. sumption cells It is similar to CB GetCorrelation CB GetCorrelation on page 162 except that it has fewer parameters and works across worksheets CB GetCorrelationByRef 163 Note For best results call CB CheckData before calling this function to ensure the latest data values are used Table 111 CB GetCorrelationByRef Returned Data Type Returned Value Returned Data Type The correlation coefficient of the two assumptions Variant Table 112 CB GetCorrelationByRef Parameters Parameter VBA Data Type Value Description AssumReference Variant In a macro Range B3 Points to one of the correlated assumption cells AssumReference2 Variant In a macro Range B3 Points to the second correlated assumption cell CB GetCorrelationByRef Example This example puts the correlation coefficient between G8 and G15 into cell H15 In a macro you can enter CB CheckData Range H15 Value CB GetCorrelationByRef Range G8 Range G15 CB GetCorrelationByRef Related Calls Name Description CB CorrelateND Defines a correlation coefficient between two selected assumptions CB GetAssum Retrieves information for a specific assumption cell CB GetCorrelation Returns the correlation between two assumption cells in a slightly different way CB GetDataAnalysisOption This function returns specified settings made by CB DataAnalysisND or the Data Analysis tool Table 113 CB GetDataAnalysisO
359. t expects CheckDataND to have completed End Sub CB CheckDataND Related Calls Name Description CB CheckData Checks Crystal Ball data cells for validity initializes variables with dialogs in case of error CB EnumAssum Enumerates assumption cells for all open workbooks CB EnumFore Enumerates forecast cells for all open workbooks CB EnumDecVar Enumerates decision variable cells for all open workbooks 76 Crystal Ball Macro Calls CB ClearData Subtopics e CB ClearData Example e CB ClearData Related Calls This subroutine prompts you to confirm and then erases assumptions decision variables or forecasts from selected cells Any values or formulas in the cells remain The worksheet must be active and the selected cell or range of cells must contain assumptions decision variables or forecasts If the range contains more than one type of Crystal Ball data a dialog appears and you can select the data types to clear Before you clear data reset the current simulation Note Before calling this subroutine select a cell or cell range containing Crystal Ball data and reset the simulation CB ClearData Example The following lines of code reset the simulation prompt the user to clear any Crystal Ball data in the currently selected cells and then clear the data CB ResetND CB ClearData The cell contents such as a value cell reference or formula remain CB ClearData Related Calls Name Des
360. t of values to be correlated DataSeries2 Variant A Microsoft Excel range address or range name that contains the second set of values to be correlated The input ranges must contain only numeric values and must have the same number of values Otherwise an error is returned and the result is NUM CB CalculateSpearman Related Calls Name Description CB CorrelateMatrixND Intercorrelates assumptions to create a correlation matrix CB CBLoaded Subtopics e CB CBLoaded Example CB CBLoaded Related Calls This function determines if Crystal Ball is loaded within Microsoft Excel Note CB CBLoaded must return True before any Crystal Ball features can be used Table 19 CB CBLoaded Returned Data Type Returned Value Returned Data Type Whether Crystal Ball is loaded within Microsoft Excel Boolean CB CalculateSpearman 67 CB CBLoaded Example To retrieve the current setting of CB CBLoaded use this call in a function as follows ReturnValue CB CBLoaded CB CBLoaded Related Calls Name Description CB GetCBAutoLoad Returns the current Crystal Ball autoload setting that indicates whether Crystal Ball is set to open whenever Microsoft Excel opens CB SetCBAutoLoad Sets or cancels autoloading with Microsoft Excel determines whether Crystal Ball is set to open whenever Microsoft Excel opens CB Shutdown Closes Crystal Ball while leaving Microsoft Excel open CB Startup Loads Cryst
361. tOnArgumentError False CB AlertOnArgumentError Related Calls Name Description CB AlertOnMacroResultError Displays a message when an execution error occurs CB AlertOnObsolete Displays a message when an obsolete call or constant is used CB AlertOnMacroResultError Subtopics e CB AlertOnMacroResultError Example e CB AlertOnMacroResultError Related Calls This subroutine displays a message when an error occurs during the execution of a subroutine or function macro Table 4 CB AlertOnMacroResultError Parameter Parameter VBA Data Type Description turnon Boolean True displays an alert message when an error occurs False switches off this alert The default is False CB AlertOnArgumentError 51 CB AlertOnMacroResultError Example This example switches on alerts when macro errors occur CB AlertOnMacroResultError True CB AlertOnMacroResultError Related Calls Name Description CB AlertOnArgumentError Displays a message when an argument error occurs CB AlertOnObsolete Displays a message when an obsolete call or constant is used CB AlertOnObsolete Subtopics e CB AlertOnObsolete Example e CB AlertOnObsolete Related Calls This subroutine displays a message when an obsolete call argument or constant is used in a subroutine or function macro Table 5 CB AlertOnObsolete Parameter Parameter VBA Data Type Description turnOn Boolean True displays an alert mes
362. tSheetName Batch Fit Results Fill results downward CB BatchFitND cbBf tOutputOrientation cbBftOutputColumns Create goodness of fit report named Fit Statistics CB BatchFitND cbBf Create assumptio CB BatchFitND cbBf CB BatchFitND cbBf Run the tool CB BatchFitND cbBf tOutputGoodnessOfFitReport True Fit Statistics n report Fit Assumption Report with full statistics tOutputAssumReport True Fit Assumption Report tOutputAssumFullStatistics True tRun CB BatchFitND Example 2 This example runs the Batch Fit tool using default preferences or settings from a previous run in the current Microsoft Excel session CB ResetND Run Batch Fit CB BatchFitND cbBftRun CB BatchFitND Related Calls Name Description CB BatchFit Launches the Batch Fit tool CB GetBatchFitOption Returns current settings for the Batch Fit tool 62 Crystal Ball Macro Calls CB Bootstrap Subtopics e CB Bootstrap Example e CB Bootstrap Related Calls This call launches the Bootstrap tool wizard This tool estimates the reliability accuracy of forecast statistics and other sample data The Bootstrap tool displays a forecast chart of the distributions for each statistic capability metric or percentile and creates a workbook summarizing the data Note Before calling CB Bootstrap reset the simulation CB Bootstrap Example This example resets the Crystal Ball simulation and opens the Boo
363. ta and charts for the current simulation To run this subroutine you must first run a simulation or the dialog does not open The simulation must be completed or stopped Once you have saved a results file with cbr extension you can use CB RestoreResults or CB RestoreResultsND to open it and restore the results CB SaveResults is similar to CB SaveRun available in Crystal Ball 2000 5 5 5 However CB SaveRun stored an entire simulation not just the results CB RestoreRun and CB RestoreRunND were used to restore the saved simulation The existing simulation had to be reset before the saved simulation could be loaded and only one simulation could be restored at a time This differs from the current requirements for CB RestoreResults and CB RestoreResultsND discussed beginning in CB RestoreResults on page 202 See the Oracle Crystal Ball User s Guide for more information on saving simulation results Note Before you save run results run a simulation CB SaveResults Example This example runs a simulation of 1000 trials and then opens the Save Results dialog CB Simulation 1000 CB SaveResults CB SaveResults Related Calls Name Description CB RestoreResults Restores simulation results from a file using a dialog CB RestoreResultsND Restores simulation results from a file without a dialog CB SaveResultsND Saves current simulation results without a dialog CB Simulation Runs a Crystal Ball simulation CB
364. tal Ball Sub Worksheet ProtectionExamplel The following call activates the target worksheet ThisWorkbook Worksheets Sheet3 Activate The following call passes current password to Crystal Ball CB WorksheetProtection passwd True The following calls run and reset the simulation CB Simulation 1000 CB ResetND End Sub CB WorksheetProtection 251 Note To apply protection to worksheets that do not have a password use this CB WorksheetProtection True CB WorksheetProtection Example 2 This example activates the target worksheet unprotects the sheet with the current password passes a new password and protects the sheet Sub Worksheet ProtectionExample2 The following call activates the target worksheet ThisWorkbook Worksheets Sheet3 Activate The following call unprotects sheet with current password CB WorksheetProtection passwd False The following call passes a new password CB WorksheetProtection passwd2 False The following call protects the sheet CB WorksheetProtection passwd2 True End Sub CB WorksheetProtection Example 3 This example activates the target worksheet unprotects the sheet with the current password clears the password by passing an empty string and leaves the sheet unprotected Sub Worksheet ProtectionExamp1le3 The following call activates the target worksheet ThisWorkbook Worksheets Sheet3 Activate The fo
365. te cell reference of the next decision variable in the format workbook sheet A 1 Variant 130 Crystal Ball Macro Calls Note For best results call CB CheckData once at the beginning of an enumeration to reset the sequence of decision variables You should also call CB CheckData each time you add or delete data or perform other actions that restructure the worksheet Use CB CheckData or CB CheckDataND with CB MacroResultDetail to check for errors For more information see the descriptions of those calls If the return string is empty all decision variables have been enumerated You can use the results of this subroutine to create a Range object You can only call this function from a subroutine or another function You cannot call this function from a worksheet CB EnumDecVar Example This example initializes all internal variables then steps through all the decision variables creates range objects from the returned string and puts their absolute cell references in column B of a worksheet CB CheckData Dim S As String Dim R As Range Dim t As Integer S CB EnumDecvar While S lt gt Set R Range S Range B2 Offset t Value s t t 1 S CB EnumDecVar Wend CB EnumDecVar Related Calls Name Description CB CheckData Checks decision variables for validity initializes variables CB EnumAssum Enumerates assumption cells for all open worksheets CB EnumFore Enumerates forecast cells for all open w
366. terPointSymbolHorizontalLine 6 Uses a horizontal line for scatter points For Index 9 Integer cbScatterPointSymbolVerticalLine 7 Uses a vertical line for scatter points For Index 9 Integer cbScatterPointSymbolCross 8 Uses a crossed line for scatter points For Index 9 Integer cbScatterPointSymbollnvertedTriangle 9 Uses an inverted triangle for scatter points For Index 14 Integer cbScatterOrderedFit 1 Specifies an ordered fit line For Index 14 Integer cbScatterRegression 2 Specifies a linear regression line For Index 16 Integer cbScatterLimitAuto 1 Automatically limits the number of trials based on plot size For Index 16 Integer cbScatterLimitTrialNumber 2 Shows only a fixed number of trials defined through Index 17 cbScatterCriteriaLimitNumber For Index 16 Integer cbScatterLimitTrialPercentage 3 Shows only the specified percentage of trials defined through Index 18 cbScatterCriteriaLimitPercentage CB ScatterPrefsND Example The following example runs a simulation with 10 000 trials and then performs the described operations to define and open a scatter chart CB Simulation 10000 CB ScatterPrefsND cbScatterManageFore The next comma The next comma nd removes all variables from a chart cbScatterRemoveAllVars nd adds forecast from D7 to the scatter chart as a target Range D7 Select CB ScatterPrefsND cbScatterManageFore cbScatterAddSelectedVar CB ScatterPrefsND cbScatterSetTarget Tru
367. termine which chart view appears See Table 25 for constants The following views are allowed frequency cumulative frequency reverse cumulative frequency capability metrics statistics percentiles and goodness of fit 104 Crystal Ball Macro Calls VBA Data Index Related Value Named Constant Value Type Value Description For Index 11 True or False Boolean n a Indicates whether forecast cbDataAnalysisFitTo Distribution charts should be fitted to a distribution True fit to distributions For Index 12 Constants Table 80 Integer See Specifies a ranking method for cbDataAnalysisRankingMethod Table 80 distribution fitting See Table 80 for constants For Index 13 True or False Boolean n a Indicates whether rank cbDataAnalysisGenerate correlations between forecast CorrelationMatrix charts should be displayed in a matrix True generate matrix For Index 14 True or False Boolean n a Indicates whether a simulation is cbDataAnalysisRunOnAllModels run on all open workbooks at the same time the selected data is analyzed True run the simulation on all open workbooks CB DataAnalysisND Example This example resets the Crystal Ball simulation and fits all distributions to a columnar data set in cells B1 through D100 including a header row Forecast charts automatically appear when the simulation runs They are fitted to a distribution The selected ranking method is Chi square The last line of c
368. th absolute cell references CB CheckData Dim S As String Dim R As Range CB Simulation 1500 s CB EnumFore While s lt gt Set r Range s r Select CB OpenFore S CB EnumFore Wend CB EnumFore Related Calls Name Description CB CheckData Checks assumptions for validity initializes variables CB EnumAssum Enumerates assumption cells for all open workbooks CB EnumDecVar Enumerates decision variable cells for all open workbooks CB GetFore Retrieves information for a specific forecast cell CB GetForePercent Returns a percentile for a forecast cell 132 Crystal Ball Macro Calls Name CB GetForeStat Description Returns a statistic for a forecast cell CB ExtractData This function extracts simulation data It opens the Extract Data dialog so you can specify the data to extract and then extract it Only call this function after you run a simulation optimization time series forecast or restore saved results Use CB CheckData before using this call CB ExtractData Example This example opens the Extract Data dialog CB Simulation 1000 CB CheckData CB ExtractData CB ExtractData Related Calls Name Description CB CreateRpt Creates a report from the current simulation and restored results optimization or time series forecast using a dialog CB CreateRptND Creates a report from the current simulation and restored results optimization or time series forecast without a d
369. the address Range M7 Value of the target forecast Range M6 Value CB GetDecisionTableOption cbDecGetTarget of the first and second selected decision variables CB GetDecisionTableOption cbDecGetDecVar cbDecVar1 Range M8 Value CB GetDecisionTableOption cbDecGetDecVar cbDecVar2 CB GetDecisionTableOption 167 Gets the number of test values for the first and second decision variables Range M9 Value CB GetDecisionTableOption cbDecSimOption _ cbDecNumValuesVarl Range M10 Value CB GetDecisionTableOption cbDecSimOption _ cbDecNumValuesVar2 Gets the maximum number of trials per simulation Range M11 Value CB GetDecisionTableOption cbDecSimOption _ cbDecSimTrials Returns the forecast chart window display setting Range M12 Value CB GetDecisionTableOption cbDecForeOption CB GetDecisionTableOption Related Calls Name Description CB DecisionTable Launches the Decision Table tool CB DecisionTableND Runs the Decision Table tool without displaying dialogs CB GetDecVar This function retrieves information for a specific decision variable cell Note For best results always call CB CheckData before calling this function to ensure the latest data values are used Table 119 CB GetDecVar Returned Data Type Returned Value Returned Data Type The specified decision variable data Variant Table 120 CB GetDecVar Parameters Parameter VBA Data
370. the code cbRunSensitivAnalysis 9 obsolete and removed from the code cbRunRetainUnsortedTrials 11 obsolete and removed from the code cbRunPrecisionWithin 45 obsolete and removed from the code cbRunLeaveOpenOnReset 50 new in Crystal Ball 7 0 cbRunMacroBeforeSimul 21 obsolete and removed from the code replaced by cbRunUserMacros 51 cbRunMacroBeforeRecalc 22 obsolete and removed from the code replaced by cbRunUserMacros 51 cbRunMacroAfterRecalc 23 obsolete and removed from the code replaced by cbRunUserMacros 51 cbRunMacroAfterSimul 24 obsolete and removed from the code replaced by cbRunUserMacros 51 cbRunMinimizeSheets 27 changed to work as described in the Value parameter section of Table 163 In Crystal Ball 2000 5 5 5 values for coRunMode 29 were booleans in later versions of Crystal Ball the values are integers Models from Crystal Ball 2000 x that use this constant will not run successfully in later versions of Crystal Ball until the constant values are edited cbRunParadiseServer 30 obsolete and removed from the code cbRunBurstAmount 33 obsolete and removed from the code New constants added include cbRunPrecisionWithin 45 coRunPrecisionConfidence 46 coRunFormatPercentiles 48 coRunSaveAssumptionValues 49 cbRunUserMacros 51 coRunCapMetrics 52 coRunCapMetricsShort 53 cbRunCapMetricsShift 54 coRunCapMetricsCalcType 55 cbRunCapMetricsNormalityThresh 56 cbRun
371. the equivalent of Analyze then Open Selected Cells It opens all charts defined for cells in the selected range Before calling this subroutine run a simulation CB OpenSelection Example This example runs a simulation of 5000 trials and then opens whatever charts are defined for cells C9 C10 C11 and C12 CB Simulation 5000 Range C9 C12 Select CB OpenSelection CB OpenSelection Related Calls Name Description CB OpenFore Opens a forecast chart for the selected cell CB Simulation Runs a Crystal Ball simulation CB OpenSensitiv This call opens the selected sensitivity chart If no sensitivity charts have been created for a model one is created for the first forecast and opened If more than one chart is found but one is not selected a chooser dialog is displayed Note This call is included for compatibility with Crystal Ball 2000 x 5 x However it differs somewhat from earlier versions For details see CB OpenSensitiv on page 267 To open a chart of a specific type by its chart ID use CB OpenChart CB OpenChart on page 196 CB OpenSensitiv Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next sensitivity chart in the workbook and then opensit CB Simulation 1000 CB CheckData CB SelectChart cbChtSensitiv CB EnumChart cbChtSensitiv CB OpenSensitiv 198 Crystal Ball Macro Calls CB OpenSensitiv Related Calls Name De
372. the first column of text cbDataAnalysisSelectLSL Integer Sets the selected range of values as forecast LSLs lower specification limit for process capability analysis The range can either be specified as a separate line preceding the CB DataAnalysisND call such as A1 C10 Select or it can be the value parameter specified as A1 C10 or similar cbDataAnalysisSelectUSL Integer Sets the selected range of values as forecast USLs upper specification limit for process capability analysis See cbDataAnalysisSelectLSL for selection examples cbDataAnalysisSelectTarget Integer Sets the selected range of values as forecast Targets target values for process capability analysis See coDataAnalysisSelectLSL for selection examples cbDataAnalysisAutoOpenCharts Integer Uses a boolean value for the Value parameter to indicate whether to open forecast charts automatically when the data analysis runs True automatically open charts cbDataAnalysisSetViewType Integer 10 If charts are shown takes cbChtChartType constants from CB ChartPrefsND as the Value parameter to determine which chart view appears See Table 25 for constants cbDataAnalysisFitToDistribution Integer 11 Uses a boolean value for the va1ue parameter to indicate whether forecast charts should be fitted to a distribution True fit to distributions cbDataAnalysisRankingMethod Integer 12 If coDataAnalysisFitTo
373. the report is produced For Index 18 True or False Boolean n a Indicates whether to output an cbBftOutputAssumReport assumption report if True the report is produced For Index 19 True or False Boolean n a Indicates whether to include full statistics cbBftOutputAssumFullStatistics with an assumption report if True the report contains full statistics including deciles For Index 21 True or False Boolean n a Indicates whether the Batch Fit tool cbBftUseDistLocking should use parameter locking if True parameter locking is set the same as checking Lock Parameters on the Fitting Options panel of the Batch Fit wizard For Index 22 True or False Boolean n a Indicates whether all statistics should cbBftOutputGoodnessOf FitAllStats appear when a Goodness of Fit report is produced the same as checking Show All Goodness of Fit statistics on the Output Options panel of the wizard if set to True all statistics appear 58 Crystal Ball Macro Calls VBA Data Related Value Named Constant Value Type Index Value Description For Index 23 The name of a lockable Integer The index Specifies one of the following cbBftFitDistLockParam distribution from number of a distributions whose parameters are Table 55 see lockable locked The following distributions from Description distribution Table 55 can be used as val1ue1 from parameters Table 55 see o Description e Gamma distribution Location S
374. three optional parameters Rescan SaveAssumValues and MultiAutoDownshift The last two were added in Crystal Ball 7 2 1 CB TrendPrefsND cbTrdForeTitleAxis 3 is now obsolete cbTypCertCenteredOnMean 2 is now obsolete cbTypCertCenteredOnMedian 4 is added Certainty band values for Index constant cbTrdCertaintyBands no longer need to be divisible by 5 Other Changes These are general changes that do not apply to a particular call Charts Module The Crystal Ball 2000 5 5 5 Developer Kit included a Charts module in the cb xla code file Because of the way charts are created in later versions of Crystal Ball that module is no longer included in the Developer Kit 210 Changes from Previous Versions Crystal Ball Runtime In This Chapter MAI A a 271 About Crystal RUIN is 271 Delivering Crystal Ball Runtime AppliCA OMS iri tetris ied Wee ed a 212 Installing Crystal Ball RUNING 2 ra aa irt eda EE Ft eot e E ebd 274 Crystal Ball Runtime Licensing Requirements cceeeeeeeeeeeee sees eeeeeseseeeeeeees 215 Introduction Application developers can use the current version of the Crystal Ball Developer Kit to create custom applications for others who are not skilled users of Crystal Ball This feature is called Crystal Ball Runtime This appendix describes Crystal Ball Runtime and explains how to install and use it About Crystal Ball Runtime When your custom application calls CB RuntimeMode
375. tion RunEF As Boolean On Error GoTo ErrorHandling From there it creates instantiates Setup and Runtime objects and resets the optimization Set PortfolioOptSetup New CBCOMDevKit OptSetup Set PortfolioOptRuntime New CBCOMDevKit OptRuntime PortfolioOptRuntime Reset Developing Optimization Code 285 This subroutine goes on to e Close any open worksheets e Create a new Portfolio Allocation workbook e Clear any previous OptQuest data e Select a primary workbook for optimization e Set up the investments e Set up the optimization e Set up Efficient Frontier analysis if requested e Configure any options e Run the optimization show the Control Panel e Get and display the optimization results e Modify the OptQuest Results window display Most of those operations are performed by calling subroutines All code is heavily commented for easier understanding Continuing For best results examine all of the sample code If something isn t clear open CB Com Devkit chm and search for the object in question From there experiment with your own code You can begin by copying OptDevKitRuntimeSample xls and modifying its code in different ways Error Handling The OptQuest Developer Kit handles the same error codes as CB MacroResult in the Crystal Ball Developer Kit However the OptQuest Developer Kit can take action when an error occurs when a non 0 error code is generated Error handling statements can take the form of On Err
376. tion for a specific assumption cell CB GetAssumPercent Returns percentile for an assumption cell CB EnumChart This function returns the unique name of the next chart of the specified type The string returned is the full path of the chart You can then use other window and chart handling calls to manage the enumerated charts Table 62 CB EnumChart Returned Data Type Returned Value The path and name of the next chart of that type ChartlD in the format Current Results Sensitivity Charts Charts xls Sensitivity Chart 1 Returned Data Type String Note For best results call CB CheckData once at the beginning of an enumeration to reset the sequence of charts You should also call CB CheckData each time you add or delete data and at other times when the structure of a worksheet is changed Use CB CheckData or CB CheckDataND with CB MacroResultDetail to check for errors For more information see the descriptions of those calls This call operates only on current results and not restored results If the returned string is empty either all charts of that type have been enumerated or there were no charts of that type to enumerate You can only call this function from a subroutine or another function You cannot call this function from a worksheet CB EnumChart has only one parameter SimChart Type which specifies the type of chart to enumerate Table 63 CB EnumChart SimChartType Parameter
377. tions 139 170 171 180 231 getting correlation 162 163 getting percentile values 152 getting statistics 154 grouping 149 224 preferences 53 retrieving information 150 selecting 219 assumptions setting attributes 225 autoload 67 160 227 242 B Batch Fit tool 54 55 155 BeforelterationEvent 289 BeforeOptimizationEvent 289 BeforeSimulationEvent 289 Bootstrap tool 63 158 C CB Com Devkit chm 279 282 295 CB AboutBox 50 CB AlertOnArgumentError 51 CB AlertOnMacroResultError 51 CB AlertOnObsolete 52 CB AssumPrefsND 53 CB AutoDownshift 53 258 CB BatchFit 54 CB BatchFitND 55 258 CB Bootstrap 63 CB BootstrapND 63 CB CalculateSpearman 67 CB CBLoaded 67 CB CellPrefs 68 CB CellPrefsND 69 258 CB ChartPrefs 71 CB ChartPrefsND 72 259 CB CheckData 74 259 CB CheckDataND 75 CB ClearData 77 259 CB ClearDataND 78 259 CB CloseAllCharts 79 CB CloseChart 79 CB CloseFore 80 259 CB CloseSensitiv 81 259 CB CloseTrend 82 CB CopyData 82 259 CB CopyDataND 83 259 CB CopyScatter 84 CB CopySensitiv 85 CB CopyTrend 86 CB CorrelateMatrixND 88 260 CB CorrelateND 86 260 CB CreateChart 90 CB CreateRpt 91 260 CB CreateRptND 92 260 CB DataAnalysis 101 Index 299 A B C DEF CB DataAnalysisND 102 CB DecisionTable 106 CB DecisionTableND 106 CB DefineAltParms 109 261 CB DefineAssum 112 262 CB DefineAssumFromForeND 117 CB DefineAssumND 113 262 CB DefineDecVar 11
378. to msiexec e qn do not display the UI e norestart do not restart e 1v lt logfile gt verbose output which writes the file c install log To add a progress bar insert passive as an argument between qn and norestart Note Using the silent install on Windows Vista is similar however you have to right click and choose Run As Administrator when opening the Vista Command Prompt 212 Crystal Ball Runtime Because the arguments passed in with the v switch are arguments to the Windows Installer msi you can use the following to perform a silent install with the Windows Installer if you have extracted Crystal Ball msi from setup exe msiexec i Crystal Ball msi qn norestart lv c install log System Requirements and NET For current system requirements for running Crystal Ball see the current Oracle Crystal Ball Installation and Licensing Guide The installation script described in the previous section will only run if all system requirements are met including the availability of Microsoft NET Framework 2 0 3 0 or 3 5 If users have another version of the Microsoft NET Framework they might get an error when starting Crystal Ball Runtime You can either instruct them to run the Crystal Ball Application Manager and check the Microsoft NET Framework 2 0 3 0 or 3 5 checkbox or you can create or update an excel exe config file to ensure Crystal Ball runs against Microsoft NET Framework 2 0 3 0 or 3 5 To
379. tribution Trials parameter Use Value3to specify the value ofthe target parameter 60 Crystal Ball Macro Calls VBA Named Data Related Value Constant Value Type Index Value Description For Index 24 The index of a Integer The index number Specifies one of the following distribution cbBftFitDistLockParamClear lockable of a lockable parameter s to clear The locking settings parameter from parameter for the and values are cleared The following from Table 55 see distribution Table 55 can be used as Value2 Description specified in parameters Value1 all from Table 55 see e Gamma distribution Location Shape Description parameters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter Hypergeometric distribution Trials parameter Table 13 CB BatchFitND Value3 Parameter Optional Variant Named VBA Data Related Value Constant Value Type Value Description For Index 23 n a Double A number within the The actual value to be used for the cbBftFitDistLockParam acceptable value range for the specified parameter according to Table 55 specified parameter Cell references cannot be used here Note Before you call CB BatchFitND reset the Crystal Ball simulation CB BatchFitND Example 1 This example resets t
380. tstrap wizard CB ResetND CB Bootstrap CB Bootstrap Related Calls Name Description CB BootstrapND Runs the Bootstrap tool without displaying dialogs CB GetBootstrapOption Returns current settings for the Bootstrap tool CB BootstrapND Subtopics e CB BootstrapND Example 1 e CB BootstrapND Example 2 e CB BootstrapND Related Calls The Bootstrap tool estimates the reliability accuracy of forecast statistics process capability metrics percentiles and other sample data This call runs the Bootstrap tool and displays results without using a dialog Note Before calling CB BootstrapND reset the Crystal Ball simulation CB Bootstrap 63 Table 14 CB BootstrapND Parameters Parameter Required VBA Data Type Table Index Required Integer Table 15 Index2 Optional Integer Table 16 Value Optional Variant Table 17 Table 15 CB BootstrapND Index Parameter Required Integer Named Constant Value Index Value Description cbBtsChooseTarget 1 Sets the target forecast for the bootstrap operation operates on the forecast in the currently selected cell cbBtsChooseDataRange 2 Selects the data values for the bootstrap operation operates on the currently selected cell range cbBtsMethod 3 Used with Index2 to specify a bootstrap method cbBtsAnalyze 4 Used with Index2 to set bootstrap analysis options cbBtsPercent 5 Used with rndex2 to specify percentile settings
381. turns cbErrNoAssumptionInCell If you enter a number outside the range 1 0 and 1 0 the subroutine deletes any correlation between the cells Seethe Oracle Crystal Ball User s Guide for more information on specifying correlations between assumptions CB CorrelateND Example 1 This example correlates cell B5 with F12 with a correlation coefficient of 0 2 Range B5 F12 Select CB CorrelateND 0 2 CB CorrelateND Example 2 This example correlates cell B12 with F5 with a correlation coefficient of 0 6 Range F5 B12 Select Range B12 Activate CB CorrelateND 0 6 CB CorrelateND Example 3 This example correlates cells B5 and B12 with a correlation coefficient of 0 3 TBC orrelateND 87 Range B5 B12 Select CB CorrelateND 0 3 CB CorrelateND Related Calls Name CB CorrelateMatrixND Description Intercorrelates assumptions to create a correlation matrix CB DefineAssum Defines or changes assumptions in selected cells using a dialog CB DefineAssumND Defines or changes assumptions in selected cells without using a dialog CB CorrelateMatrixND This function defines or updates a matrix of correlation coefficients created by correlating all member assumptions with each other in pairs Parameters in Table 28 on page 86 specify the range where the matrix is located the orientation of the coefficients and the action to take delete create or update The action taken depends on the set of
382. u should insert the following code Indicate this event was handled 288 Using the OptQuest Developer Kit Port folioOptRuntime EventHandled where PortfolioOptRuntime is an OptRuntime object This code informs the optimization engine that events are being handled and allows correct processing in the case where event handlers modify values in the Microsoft Excel workbook It does not matter where the code is placed as long as it is within the event handler Event Signatures The following are signatures for each of the event macros in OptRuntime e BeforeOptimizationEvent on page 289 e BeforelterationEvent on page 289 e BeforeSimulationEvent on page 289 e AfterSimulationEvent on page 289 e AfterIterationEvent on page 290 e AfterOptimizationEvent on page 290 e EfficientFrontierEvent on page 290 The subroutine names shown here before the underscore will change depending on the variable name assigned to OptRuntime BeforeOptimizationEvent Private Sub PortfolioOptRuntime BeforeOptimizationEvent Your code is here End Sub BeforelterationEvent Private Sub PortfolioOptRuntime BeforeIterationEvent Your code is here End Sub BeforeSimulationEvent Private Sub PortfolioOptRuntime BeforeSimulationEvent Your code is here End Sub AfterSimulationEvent Private Sub PortfolioOptRuntime AfterSimulationEvent _ IterationsCompleted As Long _ Trials As Long _ User defined Event Macros
383. ue2 Parameter Optional Variant VBA Named Data Related Value Constant Value Type Index Value Description For Index 12 True or False Boolean n a Used with va1ue1 cbBftNewWorkbook or cbBftOutputLocation cbBftNewWorksheet to indicate whether the output goes in a new workbook or worksheet If coBftNewWorksheet is set to False Value3 can be used to indicate the first upper left cell of the output range on the current worksheet Otherwise cell A1 is assumed For Index 17 A string that String n a Used with va1ue1 True to specify a report cbBftOutputGoodnessOfFitReport indicates the name string report name For Index 18 A string that String n a Used with Va1ue1 True to specify a report cbBftOutputAssumReport indicates the name string report name For Index 23 The index of a Integer The index number Specifies one of the following distribution cbBftFitDistLockParam lockable parameter from Table 55 see Description of a lockable parameter for the distribution specified in Value1 all from Table 55 see Description parameters to lock The following from Table 55 can be used as Value2 parameters e Gamma distribution Location Shape parameters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric dis
384. uns whether it stops automatically whether it runs deterministically or stochastically and more OptSetup Requirement This class is responsible for handling all operations related to OptQuest requirements Optimization Runtime Classes The following are the main OptQuest Developer Kit classes used to run optimizations and obtain results e OptRuntime main class for running an optimization and obtaining results e OptRuntime OptCounters e OptRuntime OptSolution e OptRuntime OptVarStatistics e OptRuntime OptVarSolutionFilter e OptRuntime ResultsWindow e OptRuntime RuntimeEfficientFrontier e OptRuntime TestPointInfo 280 Using the OptQuest Developer Kit OptRuntime OptRuntime is the main class for running optimizations and obtaining results OptRuntime OptCounters This class is the set of optimization counters You can use its members to count simulation iterations Efficient Frontier test points feasible solutions and more OptRuntime OptSolution This class represents a single solution in an optimization where a solution is a set of values for decision variables and their associated result values Result values can be obtained for objectives requirements and constraints OptRuntime OptVarStatistics This class represents optimization variable statistics These summarize the statistics for a single optimization variable in the current optimization They are based upon the selected statistics filter OptRuntim
385. urned DialogResult String Non localized strings describing the actions in a dialog Yes No OK Cancel and None None indicates that no dialog appeared ElapsedTimeInMS Long The time in milliseconds required to process the command To see a list of the named constants and values returned by CB MacroResultDetail NewValue open Crystal Ball online help and find Crystal Ball Error Messages in the Contents In VBA subroutines and functions you can check the returned value against either the named constants or values Table 160 Values Returned by CB MacroResult or CB MacroResultDetail OldValue Returned Constant Returned Value Description cbErrNone 0 The previous Crystal Ball command worked perfectly cbErrBadValue 1 A parameter had the wrong value 194 Crystal Ball Macro Calls Returned Constant Returned Value Description cbErrNoForecastinCell 2 The command required a forecast cell to be active the active cell did not contain a forecast cbErrNotReady 4 Crystal Ball has not yet run a simulation so the requested macro cannot be run cbErrNoAssumptioninCell 5 The command required one ortwo assumption cells to be selected One or more selected cells did not contain assumptions cbErrBadSelector 6 A parameter that was restricted to a small number of integers had a bad value cbErrBadCommand T The parm number parameter had a bad value cbErrUnsavedSheet 8 The o
386. version v2 0 50727 gt lt startup gt lt configuration gt You might also want to run against a specific version of Microsoft Excel In that case appname would be excel and you would be modifying a file called excel exe config Predictor Developer Kit Namespace The Predictor Developer Kit contains the following main namespace Decisioneering CB CBCOMDevKit This namespace contains the classes required to set up and run time series forecasts with the Predictor Developer Kit Note CB Com Devkit chm on page 282 describes a reference help file that summarizes all the OptQuest and Predictor Developer Kit objects and shows the hierarchy of the development system When you first open CB Com Devkit chm three namespaces appear in the navigation pane Figure 2 These namespaces are only used in C code not Visual Basic VBA code However if you are using VBA they indicate which classes are used for OptQuest automation Optimization and which are used for Predictor Predictor When writing VBA code you omit Optimization or Predictor as shown in the code examples included in this Developer s Guide Important Predictor Classes Two categories of important classes in the Predictor Developer Kit e Predictor Setup Class on page 296 e Predictor Results Class on page 297 Other classes support those two areas of functionality For lists and descriptions of methods and properties in Predictor namespace classes open
387. vironment lets you use VB6 VBA supplied with Microsoft Word and Microsoft Excel C ASP and similar COM compatible languages you will still need the Microsoft NET Framework To access the Predictor Developer Kit you must reference the COM object named CBCOMDevkKit which is registered on your computer during the installation In addition to this book the Predictor Developer Kit contains two other files with information about kit contents and how to use it CB Com Devkit chm and Toledo Gas xls CB Com Devkit chm is a reference help file with lists and descriptions of methods and properties in Predictor Developer Kit classes It also contains information on the OptQuest Developer Kit available with Oracle Crystal Ball Decision Optimizer For more information about CB Com Devkit chm see CB Com Devkit chm on page 282 Although the information there refers to the OptQuest Developer Kit the information is basically the same for the Predictor Developer Kit Be aware that class names are different as described in Important Predictor Classes on page 295 Toledo Gas xls is a Crystal Ball example file used as a tutorial example in the Oracle Crystal Ball Predictor User s Guide It contains annotated code that performs similar tasks to those described in the Predictor User s Guide To view the Predictor Developer Kit sample code 1 Open Toledo Gas xls From the Window task bar you can select Start then All Programs then Oracl
388. wCapMetrics 3 Returns a boolean value2 parameter to specify whether cbTwoDOutputOption Integer to include capability metrics in the output report if followed by True includes capability metrics in the report For Index 7 cbTwoDPercent cbTwoDPercentTenNinety 1 Returned by cbTwoDPercentto indicate the 10th and 90th Integer percentiles For Index 7 cbTwoDPercent cbTwoDPercentFiveNinetyFive 2 Returned by cbTwoDPercent to indicate the 5th and 95th Integer percentiles For Index 7 cbTwoDPercent cbTwoDPercentQuartiles 3 Returned by cbTwoDPercent to indicate quartiles 25 Integer ile increments from 0 to 100 inclusive For Index 7 cbTwoDPercent cbTwoDPercentQuintiles 4 Returned by cbTwoDPercent to indicate quintiles 20 Integer ile increments from 0 to 100 inclusive For Index 7 cbTwoDPercent cbTwoDPercentDeciles 5 Returned by cbTwoDPercent to indicate deciles 10 ile Integer increments from O to 100 inclusive For Index 7 cbTwoDPercent cbTwoDPercentlcosatiles 6 Returned by cbTwoDPercent to indicate icosatiles 5 ile Integer increments from 0 to 100 inclusive For Index 7 cbTwoDPercent cbTwoDPercentCustom 7 Returned by cbTwoDPercent to indicate custom Integer percentiles If coTwoDPercentCustom is supplied as a parameter along with a valid Microsoft Excel range fills a column oriented range with percentiles in the custom list starting with the cell passed in the range
389. windows can help speed up long simulations MinimizeHost Optional Variant True or False Sets whether to minimize Microsoft Excel during simulations True or not False Minimizing Microsoft Excel can help speed up long simulations This parameter only works in Normal or Demo speed not Extreme speed MinimizeAllSheets Variant True or False Sets whether to minimize worksheets during simulations True or not Optional False Minimizing worksheets can help speed up long simulations This parameter only works in Normal or Demo speed not Extreme speed StatusString Optional Variant Words Inserts a string into the status bar during the simulation If this is omitted surrounded by no special string appears quotes ShowContro1 Panel Boolean True or False Sets whether to show the Crystal Ball Control Panel during simulations Optional True or not False Hiding it can help speed up long simulations The default is False for simulations run through the Crystal Ball Developer Kit This parameter is new for Crystal Ball versions later than 5 5 CB Simulation Example 1 This example resets any previously run simulation and runs a simulation of 1000 trials Following call makes sure the trials begin at 1 CB ResetND CB Simulation 1000 CB Simulation Example 2 This example switches to Normal speed and runs a simulation of 100 000 trials Because of the lengthy number of trials all the timesaving options
390. xAdjAsms indicates that the defined assumptions to be correlated are located next to the matrix either to the left or above it 3 cbCorrMatrixAdjAsmNames indicates that the names of the assumptions to correlate are next to the matrix either to the left or above it 4 cbCorrMatrixCellRange specifies a single contiguous range of assumptions length of long dimension must match MatrixLocation dimensions AssumSelectionRange Microsoft A contiguous or All contained assumptions are loaded the number of assumptions Optional Excel discontiguous set of must match MatrixLocation dimensions used with Range cell ranges such as AssumSelectionType 0 cbCorrMatrixDelete and Range A1 A10 AssumSelectionType 4 cbCorrMatrixCellRange B5 FormatMatrix Optional Boolean True Or False Indicates whether to format the matrix with borders and shading True or leave it unformatted False if unspecified the current format is not modified AddNames Optional Boolean True Or False Indicates whether to add assumption names to the matrix True or remove them False default False Note For AssumSelect ionType 4 users cannot order the assumptions as they can with the user interface If a reordered matrix is updated with this call assumption order will be set to their order of occurrence in the range For AssumSelectionType cbCorrMatrixAdjAsms or cbCorrMatrixAdjAsmNames the range to the left of MatrixLocatio
Download Pdf Manuals
Related Search
Related Contents
Philips 66661/11/66 TA-35A/722M Code des marchés publics Code des marchés publics NXN-20CSL User Manual Ecostar 430F 3073-Notice Supralys 1 Philips Filter basket CRP410 Mode d`emploi Copyright © All rights reserved.
Failed to retrieve file