【问题标题】:Non-numeric unique combinations [duplicate]非数字唯一组合[重复]
【发布时间】:2013-12-07 15:50:53
【问题描述】:

我有三类非数字值,需要编写代码来要求它创建所有可能的组合,其中 Excel 中的每个类别都有一个值。

以下是类别:

Category1
OA1
OA2
OA3

Category2
SE
EcoCo
TripleA
Field

Category3
Group1
Group2
Group3

一种可能的组合是:OA1、SE、Group1

我对编程很陌生...有人可以指导我从哪里开始吗?我不知道该使用哪些公式。谢谢!

【问题讨论】:

    标签: excel combinations permutation vba


    【解决方案1】:

    您需要查看 vba 循环 (http://office.microsoft.com/en-us/training/nested-loops-RZ001150634.aspx?section=13)。本质上,您将遍历所有 Category1,并且对于每个项目,将遍历所有 Category2,并且对于每个项目,将遍历所有 Category3。

    伪代码:

    foreach(Category1) {
        foreach(Category2) {
            foreach(Category3) {
                print Category1.value + ", " + Category2.value + ", " + Category3.value;
            }
        }
    }
    

    更多类似 Excel VBA 的内容(不完整且未经测试,但应该将您推向正确的方向):

    For Each Category1 In Selection
        For Each Category2 In Selection
            For Each Category3 In Selection
                //do something here
            Next
        Next
    Next
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-31
      • 1970-01-01
      • 1970-01-01
      • 2018-08-15
      • 1970-01-01
      • 2018-11-16
      • 1970-01-01
      相关资源
      最近更新 更多