じゃんけんプロレス
id:totsuanさんのじゃんけんプロレスの結果を集計するためのマクロです。
http://q.hatena.ne.jp/1222357834
じゃんけんプロレスでは全員と対戦するということなので190試合にもなるようです。
その場合、手作業だとかなり大変でミスもありそうなので結果を自動化するマクロを作ってみました。
以下のような表をシートに作成し、A列B列C列に参加者のデータを入力します。
簡略化のため、G=グー、C=チョキ、P=パー、フォールするときは○、それ以外は×
ライバルと書かれたセルの下の番号がライバルです。
以下が、結果を表示するためのマクロです。
参加人数を少なくするには1行目の20を変更してください。
Option Explicit Sub Macro() Const MaxPlayer As Integer = 20 Dim i As Integer Dim j As Integer Dim k As Integer Dim A(2) As String Dim D(2) As String Dim AF(2) As String Dim DF(2) As String Dim res As String Dim P As Integer Dim R As Integer Dim f As Boolean For i = 1 To MaxPlayer For k = 0 To 2 A(k) = Cells(i * 3 + k - 1, 2).Value AF(k) = Cells(i * 3 + k - 1, 3).Value Next k P = 0 R = Cells(i * 3 + 1, 1).Value For j = 1 To MaxPlayer f = False If i <> j Then For k = 0 To 2 D(k) = Cells(j * 3 + k - 1, 2).Value DF(k) = Cells(j * 3 + k - 1, 3).Value Next k res = Syoubu(A(0), D(0), AF(0), DF(0)) Cells(i * 3 - 1, j + 3).Value = res If res = "F勝ち" Then f = True Else If res <> "F負け" Then res = Syoubu(A(1), D(1), AF(1), DF(1)) Cells(i * 3, j + 3).Value = res If res = "F勝ち" Then f = True Else If res <> "F負け" Then res = Syoubu(A(2), D(2), AF(2), DF(2)) Cells(i * 3 + 1, j + 3).Value = res If res = "F勝ち" Then f = True Else If res <> "F負け" Then End If End If End If End If End If End If If f Then If j = R Then P = P + 3 Else P = P + 1 End If End If End If Next j Cells(i * 3 - 1, MaxPlayer + 4).Value = P Next i End Sub Function Syoubu(p1 As String, p2 As String, AF As String, DF As String) As String Dim str As String Select Case p1 Case "G" Select Case p2 Case "G" str = "引き分け" Case "C" str = "勝ち" Case "P" str = "負け" End Select Case "C" Select Case p2 Case "G" str = "負け" Case "C" str = "引き分け" Case "P" str = "勝ち" End Select Case "P" Select Case p2 Case "G" str = "勝ち" Case "C" str = "負け" Case "P" str = "引き分け" End Select End Select If str = "勝ち" And AF = "○" Then str = "F勝ち" End If If str = "負け" And DF = "○" Then str = "F負け" End If Syoubu = str End Function