求助,Excel2003代码问题,非常感谢!

如题所述

第1个回答  2019-02-15
Public xrow As Integer, xcol As Integer
Private Sub CommandButton1_Click()
    If xrow = 0 Then
        xrow = 2
        xcol = 3
    End If
    If xrow > 441 Then
        xrow = 2
        xcol = 3
    End If
    If xcol > 7 Then
        xcol = 3
        xrow = xrow + 1
        If xrow > 441 Then xrow = 2
    End If
    Sheet1.Cells(xrow, xcol).Value = Val(CommandButton1.Caption)
    xcol = xcol + 1
End Sub
'这是一个命令按钮的代码

追问

非常感谢老师,代码只对数字1那个按钮好用,2-11那10个按钮点击都不显示数字,再麻烦老师您帮我看一下,拜托了!

追答

你把commandbutton1_click和end sub之间的代码复制到其他commandbutton的click事件里面就可以了,注意修改一下Sheet1.Cells(xrow, xcol).Value = Val(CommandButton1.Caption)中commandbutton1.caption中的1,你按钮是几就修改为几

追问

非常感谢老师,我明白了。

本回答被提问者采纳
相似回答