
以下のコードをコピーして貼り付ければゲームができます。
Private i As Byte, i2 As Byte, i3 As Byte Private Num As Byte Private Number(1 To 25) As Byte Private StartTime As Long Private GameFrag As Boolean Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If GameFrag = True And Cells(2, 2).Interior.ColorIndex > 30 Then GoTo Ido Randomize GameFrag = True i = 0: i3 = 1 Cells(1, 2) = "15・ム・コ・・quot; Cells(1, 2).Font.Size = 30 Rows("2:5").RowHeight = 55 Range("B2:E5").Font.Size = 35 Range("B2:E5").Font.ColorIndex = 5 Range("B2:E5").HorizontalAlignment = xlCenter Range("B2:E5").VerticalAlignment = xlCenter Range("B2:E5").Borders(xlEdgeLeft).LineStyle = xlContinuous Range("B2:E5").Borders(xlEdgeTop).LineStyle = xlContinuous Range("B2:E5").Borders(xlEdgeBottom).LineStyle = xlContinuous Range("B2:E5").Borders(xlEdgeRight).LineStyle = xlContinuous Range("B2:E5").Borders(xlInsideVertical).LineStyle = xlContinuous Range("B2:E5").Borders(xlInsideHorizontal).LineStyle = xlContinuous Num = Int(3 * Rnd) + 1 Select Case Num Case 1: Range("B2:E5").Interior.ColorIndex = 36 Case 2: Range("B2:E5").Interior.ColorIndex = 35 Case 3: Range("B2:E5").Interior.ColorIndex = 34 End Select Do Until i = 15 i = i + 1 1: Num = Int(15 * Rnd) + 1 For i2 = 1 To i If Num = Number(i2) Then GoTo 1 End If Next i2 Number(i) = Num Loop For i = 2 To 5 For i2 = 2 To 5 Cells(i, i2) = Number(i3) i3 = i3 + 1 Next i2 Next i Range("E5").ClearContents StartTime = Timer Ido: If ActiveCell.Interior.ColorIndex = xlNone Or GameFrag = False Then Exit Sub If ActiveCell.Offset(1, 0).Interior.ColorIndex > 30 And ActiveCell.Offset(1, 0) = "" Then ActiveCell.Offset(1, 0) = ActiveCell.Value Activecell = "": ActiveCell.ClearContents End If If ActiveCell.Offset(-1, 0).Interior.ColorIndex > 30 And ActiveCell.Offset(-1, 0) = "" Then ActiveCell.Offset(-1, 0) = ActiveCell.Value Activecell = "": ActiveCell.ClearContents End If If ActiveCell.Interior.ColorIndex = xlNone Then Exit Sub If ActiveCell.Offset(0, 1).Interior.ColorIndex > 30 And ActiveCell.Offset(0, 1) = "" Then ActiveCell.Offset(0, 1) = ActiveCell.Value Activecell = "": ActiveCell.ClearContents End If If ActiveCell.Offset(0, -1).Interior.ColorIndex > 30 And ActiveCell.Offset(0, -1) = "" Then ActiveCell.Offset(0, -1) = ActiveCell.Value Activecell = "": ActiveCell.ClearContents End If i3 = 1 For i = 2 To 5 For i2 = 2 To 5 Number(i3) = i3 If Cells(i, i2) <> Number(i3) Then Exit Sub i3 = i3 + 1 If i3 = 16 Then MsgBox Int(Timer - StartTime) & "ノテ" GameFrag = False End If Next i2 Next i End Sub