多个命令按钮依次排列

Multiple command buttons in sequence with one another

我是编程新手,我想为篮球教练创建一个应用程序,以便能够通过在 Excel 中使用 VBA 和命令按钮来保持他们球员的统计数据。

我希望能够单击带有玩家姓名的命令按钮到 select 该玩家所在的行,而不是手动输入游戏中每个玩家的统计数据。然后单击一个将对其执行操作的按钮并输入一个数字。

我将有 12 个球员按钮和 40 个动作按钮(例如 pts、reb、stl 等)

例如:当我点击球员名称按钮时,它会select球员属性所在的行。然后当我select动作(例如积分)时,它会添加标记为点的列的数字 2。

我想对所有 12 个玩家使用操作按钮,所以只有在我单击玩家姓名按钮时才输入数字。所以 "pts" 按钮将适用于所有 12 个播放器按钮。总的来说,我想用命令按钮为教练制作一个统计数据 sheet,而不是移动光标并手动输入信息。

关于如何操作有什么建议吗?提前谢谢你。

克兰西

一些示例代码,使用模块范围的变量来存储正在处理的播放器,可能是:

Option Explicit

Private CurrentPlayerRow As Long

Sub PlayerA_Click()
    CurrentPlayerRow = 3
End Sub
Sub PlayerB_Click()
    CurrentPlayerRow = 4
End Sub
Sub PlayerC_Click()
    CurrentPlayerRow = 5
End Sub

Sub Action1_Click()
    'Update column D by adding 2 to the cell value
    Cells(CurrentPlayerRow, "D").Value = Cells(CurrentPlayerRow, "D").Value + 2
End Sub
Sub Action2_Click()
    'Update column G by adding an inputted number to the cell value
    Cells(CurrentPlayerRow, "G").Value = Cells(CurrentPlayerRow, "G").Value + CLng(InputBox("Enter a number:"))
End Sub

(对篮球得分 and/or 统计一无所知,我不确定你想要处理什么样的动作。)