Hi,
I'm new to visual basic and have been using Excel for some time. I have searched the forums for a solution to my problem and the closest I have is from http://www.excelforum.com/showthread...t=combinations however... I don't understand the solution.![]()
My Problem:
On one sheet (input) I ask a user to input the number of variables to be considered (e.g. 2 variables). On another sheet (States) I read in the number of variables and ask the user to input a number of states for each variable (e.g. variable 1 has x states, variable 2 has y states). Once the user inputs the number of states I then ask then user to input the names of each state for each variable (e.g. State 1 for variable 1 = True, State 2 for variable 1 = False, State 1 for variable 2 = True, State 2 for variable 2 = False). The number of variables and the number of states can vary.
I have managed to create VB macros to this point and now I am stuck. I would like read in the states and create a table with all possible combinations in the cells. E.g. if there are 2 variables there will be two columns and, using the example above, the table will look like:
Variable 1 Variable 2
True True
True False
False True
False False
If there are 3 binary true/false variables the table becomes:
Variable 1 Variable 2 Variable 3
True True True
True True False
True False True
True Flase False
False True True
False True False
False False True
False False True
The state inputs always start in cell E1 in the states sheet with a space after each variable state list. E.g. if variable 1 has 2 states they will be listed in E1 and E2, Variable 2 states will start in E4.
Can anyone help? I hope I have provided enough information.
Mbrolass.
Bookmarks