宏给出所有可能的结果

时间:2014-02-04 22:47:08

标签: excel vba excel-vba math excel-2013

我对可能的结果有疑问。

每周有9场比赛,每场比赛有3种可能的结果:

  • 主页(H)胜利
  • 离开(A)胜利
  • 画(D)

是否有一个宏可以为我提供所有游戏的所有可能的结果组合。

enter image description here

1 个答案:

答案 0 :(得分:0)

希望这有帮助

Dim i, j, rowloc, teams As Integer
Dim result(2) As String

result(0) = "H"
result(1) = "A"
result(2) = "D"
teams = 9

For i = 0 To 2
    For j = 1 To teams
        rowloc = i * teams + j
        Worksheets("Sheet1").Cells(rowloc, 1).Value = "Team " & j
        Worksheets("Sheet1").Cells(rowloc, 2).Value = result(i)
        Worksheets("Sheet1").Cells(rowloc, 3).Value = "Team " & j + teams
    Next
Next