Script to Loop Copy/Paste with Calc

2.39K viewsScriptingCopyPastScript formula Loop model scripting
0

Hello,
In excel, via VBA, I’m familiar with setting up a loop that would allow me to copy/paste from one cell to another.  How do I achieve a similar event in Quantrix through scripting?

Use case – We have items in our model that are dependent on results from a prior time horizon.  I want to step through a copy/paste for the first item related to our timeframe, calculate the model, and then repeat the process until all timeframes are complete.

Gilbert Posted new comment
0

Hi,

You should mostly NEVER have to copy/paste values in Quantrix. What you want to do is probably very easily and cleanly solvable by adding another dimension (category) – if I understood your usecase right.

I suggest that you make a very simple example model what you want to achieve, and I (or somebody else here) will be happy to try to suggest a “Quantrix way” to do it!

Gilbert

P.S.: I know of one exception of the above rule: if by purpose want to break the end-to-end data flow of your model, e.g. because the input values are going to change, but you do not want to change the already calculated results. This is e.g. the case in my Monte-Carlo-model, where I on purpose use this kind of “air gap” achievable by copy-paste data by script. So yes, it is possible to write a script to do so. But again, if this is really what you want, working on a example model will help. Just as an example as I did it as a newbie to script:

// Define Target: Write the KPI into the iteration in the KPI_Results matrix
      RangeTo   =   "Iter" + i.toString()  // we copy to the MC-Iteration i
       TargetSelection = model.matrices[IterationMatrix].getSelection(RangeTo)
           // copy values
           TargetSelection.values = model.matrices[KPIDefMatrix].categories["KPI"].values

You find the help to the script here: https://quantrix.com/help/scripting/Model.html or simpler in the Scripting Console by starting to type an see the object browser help.

Or send me a mail at solutions@brainwork.consulting for help.

dh Posted new comment

Thanks for your feedback Gilbert! We were able to find a work around.

You are viewing 1 out of 1 answers, click here to view all answers.