表的格式我是严格按照你的表格来了,VBA代码如下:
Private Sub ToggleButton1_Click()
For C = 2 To 28 Step 2
For R = 2 To 12 Step 2
If Cells(R, C).Value = "" Then
Cells(R, C).Value = "A"
Cells(R, C).Font.Color = RGB(125, 12, 15)
Cells(R, C).Font.Bold = 1
GoTo oT02
End If
Next
Next
oT02:
End Sub
-------------------------------------------------
Private Sub ToggleButton2_Click()
For C = 2 To 28 Step 2
For R = 2 To 12 Step 2
If Cells(R, C).Value = "" Then
Cells(R, C).Value = "B"
Cells(R, C).Font.Color = RGB(12, 14, 185)
Cells(R, C).Font.Bold = 1
GoTo oT01
End If
Next
Next
oT01:
End Sub
上述是两段宏,可以复制在一起,先在编辑模式下的“属性”下查看按钮Name属性,修改第一句Sub和 _Click之间为按钮名字(默认一般不用改)
保存后重新启动,同意运行宏,就可以随便操作了。
(有问题细节或不太清楚的地方可追问)
按钮用 文本框