If MsgBox("请选择", vbQuestion + vbYesNo, "提示") = vbNo Then
Exit Sub'选择NO
Else
'此地可写执行任务
MsgBox “选择是”
End Sub
Private Sub CommandButton1_Click()
With CommandButton1
If MsgBox("确定增加?", vbQuestion + vbYesNo) = vbYes Then
.Caption = Round(.Top / [A1].Height, 0) + 1 '获取按钮所在位置对应的单元格行数
ActiveSheet.Rows(Val(.Caption) + 1).Insert shift:=xlShiftDown '插入空行
End If
End With
End Sub
yn = MsgBox("确定增加:")
If yn = vbYes Then
你要执行的代码
end if
就这样