View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Auric__ Auric__ is offline
external usenet poster
 
Posts: 538
Default VBA to run all variable combinations in a calculation model and store result

yves.mosselmans wrote:

I received a workbook with a calculation model which calculates a price
based on 6 different criteria and complex formulas. There are over
40,000 possible combinations, choosing different criteria.

I managed to create a table with all possible combinations. Criteria 1
is stored in Column A, Criteria 2 is stored in Column B, etc up to 6
columns. I can't use a formula for this.


Would it be possible to create a vba code to run all combinations in the
calculation model and store the result in the last column?


A very simplified example could be (using 2 variables in 2 columns):

Col 1 (Month) Col 2 (Rateplan)
January Gold
February Silver
March
April
...

The calculation model could be
Month (data validation from Col 1)
Rateplan (data validation from Col 2)
Charge = formula that calculates the charge based on two above criteria


In this example a Combination could be January and Gold... I would like
the macro to run this (and all other) combination in the calculation
model and store the outcome as a value in Column 3 (next to the
combination).


Could a vba wizzard help me with this?


Not without more information.

With your table, I'm assuming it lists each criterion once, right? (Meaning,
for example, January thru Dcember listed once, not 40,000 times.)

Also, what is the final output in the 7th column supposed to look like? Is it
supposed to be literally "January Gold etc." or something else?

--
Who's gonna fight for the weak?
Who's gonna make 'em believe?