我试图让 Excel 单元格看起来像按钮而不实际插入按钮。
For Each myCell In Range(BoardSize)
With myCell
.Borders.LineStyle = xlContinuous
.Borders.Weight = xlThick
.Borders.Color = RGB(110, 110, 110)
.Interior.Color = RGB(180, 180, 180)
End With
myCell.Borders(xlEdgeTop).Color = RGB(255, 255, 255)
myCell.Borders(xlEdgeLeft).Color = RGB(255, 255, 255)
Next myCell
Run Code Online (Sandbox Code Playgroud)
它适用于一个单元格:
但在很大范围内,它看起来像这样:
我想要的是不使用实际命令按钮的东西,例如:
H!我是VBA的新手.这可能是一个太简单的问题,但我正在努力使用VBA:当单击一个单元格(1,1),因为它有1,msgbox会显示"hi"
Sub test()
'click action 'when cell(1,1) is clicked and if cells(1,1) is 1, msgbox saying "hi" will show up, if not nothing If Cells(1, 1) = 1 Then
MsgBox "hi"
Else
End If
End Sub
Run Code Online (Sandbox Code Playgroud)