Make Cell Trigger to Reset Assumptions

2 posts / 0 new
Last post
Khang A+ 1
Make Cell Trigger to Reset Assumptions

Hi Brains trust,

Is it possible to make a cell trigger to reset assumptions to the active module component/cell block?

Eg. Occurs when a change in module name, cell value or date will trigger a reset of assumptions?

Thanks

Michael Hutchens A+ 189

Hi Khang,

While there is no in-built Reset Assumptions cell block trigger type, you can always select the Run Macro type and include a macro in your modular workbook which resets the assumptions within a specified cell block.

The best way to programmatically reset assumptions within cell blocks is to use the latest Modano VBA API, which you can download using this link: https://app.modano.com/api/latest

There's this example code in the mExamplesCellBlocks module:

Sub Reset_Selected_Cell_Block_Assumptions()
    
    'Demonstrates the resetting of the assumptions within the cell block containing the selected range:
    
    'Private declarations:
    Dim fContinue As Boolean
    Dim strError As String
    Dim modappConnection As New ModanoApplication
    
    'Checks for valid connection:
    fContinue = modappConnection.ValidConnection(Nothing, False)

    'Gets the projects collection:
    If fContinue Then
        If modappConnection.CellBlockAssumptionsReset(Application.Selection, False, False, False) Then
            Call MsgBox("The selected cell block assumptions were reset.", vbInformation, "Modano API")
        End If
    End If

End Sub

If you have some VBA skills you can refactor this code to write a macro to reset the assumptions within a specific cell block triggered by a cell block trigger.

I always add a range name to the cell block(s) being referenced by VBA using the API to ensure that the cell block range is correctly detected even after users scale or edit their model and cause things to move around.

The Modano VBA API is extremely powerful and very cool stuff if you know how to use VBA. We use it for all sorts of weird and wonderful things, both for specific user requirements and when building and maintaining our content libraries.

I hope this helps.

Michael