【问题标题】:VBA macro to list all the combinations in a rowVBA宏以连续列出所有组合
【发布时间】:2016-04-12 08:20:08
【问题描述】:

我对 VBA 比较陌生,目前正在尝试编写一个超出我能力范围的宏。

基本上,我希望在表格的行中列出所有可能的组合,例如:

Gas Diamonds Graphite Graphene
Red Blue Black

会变成

Gas Diamonds
Gas Graphite
Gas Graphene
Diamonds Graphite
Diamonds Graphene
Graphite Graphene
Red Blue
Red Black
Blue Black

表格最多有 5 列。

任何帮助将不胜感激!

提前致谢

【问题讨论】:

  • 您是否尝试过编写任何代码?发布您尝试过的代码示例将使我们能够为您提供更多有用的反馈。这个论坛上有几个代码示例可以作为这个问题的一个很好的起点。

标签: vba excel macros


【解决方案1】:

尝试获取一列中的元素个数

Dim Lastcolumn
With ActiveSheet
   LastColumn = .Cells(2, .Columns.Count).End(xlToLeft).Column
End With

遍历组合数并用“Cells(x,y)”显示

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-25
    • 1970-01-01
    • 2022-01-21
    • 2018-06-17
    • 2015-11-25
    • 2019-04-08
    • 1970-01-01
    相关资源
    最近更新 更多