Tag: commandbutton

获取单元格中的CommandButton名称/ ID

我有一个单元格与CommandButtons的电子表格。 我只是想在没有button被点击的情况下获取特定单元格中的命令button的名称/ ID。 我怎么能去呢? 我一直在使用这个代码,但效率不高,因为我必须逐个键入每个buttonID。 我有大约60个button。 Sub Worksheet_Calculate() If Cells(6, 3).Value = 0 Then Me.Buttons("Button 55").Enabled = False Me.Buttons("Button 55").Font.ColorIndex = 16 Else Me.Buttons("Button 55").Enabled = True Me.Buttons("Button 55").Font.ColorIndex = 1 End If If Cells(7, 3).Value = 0 Then Me.Buttons("Button 61").Enabled = False Me.Buttons("Button 61").Font.ColorIndex = 16 Else Me.Buttons("Button 61").Enabled = True Me.Buttons("Button 61").Font.ColorIndex = […]

CommandButton单击与从VBA编辑器执行,

已更新================================================= ========== 所以我整晚都在debugging..还是不知道是怎么回事 如果你看看这两个捕获的图像… 基本上,进入下一行不应该改变select的选项卡,如下所示。 这是如果我从VBA编辑器中单击F5执行该子项会发生什么情况 但是,当我真正运行它使用链接的命令button,假设是做完全相同的事情(照片显示在线程)。 但是会发生什么呢? 进入下一行实际上改变了标签! 有第一个断点行,告诉Excelselect另一个选项卡…为什么这样做。 如果我使用F8运行它,实际上这个问题会消失。 已更新================================================= ============ 我在Excel VBA中遇到了一些奇怪的行为,无法解释为什么它会这样做。 Sub run_simulation() ActiveWorkbook.Worksheets("Run Simulation").Select ActiveSheet.CommandButton1.value = True End Sub 这个子程序select一张纸,然后模拟一个button“CommandButton1”的点击。 当我从VBA编辑器中的播放图标执行它,它运行良好,但是当我从另一个工作表上的链接button运行这个“run_simulation”子例程…这样 一个错误返回说,所选工作表“run_simulation”是受保护的,并且在继续之前需要不受保护…事情是在单击commandButton1时自动取消保护工作表。

单击后,将ActiveX命令button颜色更改回到以前的颜色

我有一个超过65个ActiveX命令button的电子表格。 当我离开时单击一个命令button,它变成绿色,并在单元格中添加(+1)。 当我右键单击相同的命令button,它变成红色,并在单元格中添加(+1)。 当我点击另一个命令button时,我想将上一个命令button返回到默认的灰色。 问题是前面的命令button保持与我之前点击过的相同的颜色。 如何使单击的命令button返回到默认灰色,当表单上有65个以上的命令button时。 这是我到目前为止的一个单一的命令button: Private Sub Action68_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) If Button = 1 Then Worksheets("Stats").Cells(CurrentPlayerRow, "BA").Value = Worksheets("Stats").Cells(CurrentPlayerRow, "BA").Value + 1 Action68.BackColor = vbGreen ElseIf Button = 2 Then Worksheets("Stats").Cells(CurrentPlayerRow, "BB").Value = Worksheets("Stats").Cells(CurrentPlayerRow, "BB").Value + 1 Action68.BackColor = vbRed […]