Button for suggesting a new unique row combination

2019-08-27 02:49发布

lets say we have the following table:

    A   B   C
1 | x | X | X |
2 | y | X | X |
3 |   |   |   |

In cells A1-A3 we have a dropdown list with 2 options: [x,y]
In cells B1-B3 we have a dropdown list with 2 options: [x,y]
In cells C1-C3 we have a dropdown list with 2 options: [x,y]

Is it possible to create a button that suggests to the user a new combination that it wasn't already submitted on the previous rows ?

For example it would suggest that on row 3, he can select any of the following: "yyy/yyx/xyx/ etc.." or even to pick any of the possible suggestions and display it (just one)

标签: excel button
1条回答
混吃等死
2楼-- · 2019-08-27 03:41

Sure. But with VBA. The VBA can look like the following:

  1. Generate a list or array with all possible permutations of your rows.
  2. Do a loop to iterate through all rows, removing a permutation if it occurs in your row
  3. Show in a MsgBox which permutations are available

We can't write the code for you but we can help you find the answers.

Links to help you get started:

  1. Permutations: http://www.excelcasinogames.com/excel-vba-permutation-macro-code.html
  2. Collections (first random link in Google): http://maffelu.net/using-collections-in-vba/
  3. For loops: http://msdn.microsoft.com/en-us/library/5z06z1kb.aspx
查看更多
登录 后发表回答