Sub auto()
Dim x As Integer
If Len(Sheet2.Range("f3")) <> 0 Then
MsgBox ("先清除,后起新卦")
Exit Sub
End If
With Sheet2
.Cells(4, 1).Value = Application.WorksheetFunction.RandBetween(0, 1)
.Cells(4, 2).Value = Application.WorksheetFunction.RandBetween(0, 1)
.Cells(4, 3).Value = Application.WorksheetFunction.RandBetween(0, 1)
.Cells(4, 4).Value = Application.WorksheetFunction.RandBetween(0, 1)
.Cells(4, 5).Value = Application.WorksheetFunction.RandBetween(0, 1)
.Cells(4, 6).Value = Application.WorksheetFunction.RandBetween(0, 1)
For x = 1 To 6
If .Cells(4, x).Value = 1 Then
.Cells(3, x) = "O"
Else
.Cells(3, x) = "X"
End If
Next
End With
End Sub
单独起卦:
[Visual Basic] 纯文本查看复制代码
Sub Õy()
Dim i
With Sheet2
i = .Cells(3, Columns.Count).End(xlToLeft).Column + 1
If Len(.Range("f3")) <> 0 Then
MsgBox ("请清除以后,起新卦")
Exit Sub
End If
If Len(.Range("a3")) = 0 And Len(.Range("f3")) = 0 Then
.Range("a3").Value = "O"
.Range("a4").Value = 1
Else
.Cells(3, i) = "O"
.Cells(4, i) = 1
End If
End With
End Sub