Excel 通过第一个命令在发布数据后添加要运行的宏
我有两个按钮命令,第一个用于发布数据,第二个用于运行宏 如何在一个按钮中合并这两个命令? 因为我需要发布数据,然后运行宏Excel 通过第一个命令在发布数据后添加要运行的宏,excel,vba,Excel,Vba,我有两个按钮命令,第一个用于发布数据,第二个用于运行宏 如何在一个按钮中合并这两个命令? 因为我需要发布数据,然后运行宏 Private Sub post_Click() If Me.today.Value = "" Then MsgBox " You should enter contract date " Exit Sub End If If Not (Me.percentage.Value = "" Xor Me.txtamount
Private Sub post_Click()
If Me.today.Value = "" Then
MsgBox " You should enter contract date "
Exit Sub
End If
If Not (Me.percentage.Value = "" Xor Me.txtamount.Value = "") Then
MsgBox "You should select % or amount"
Exit Sub
End if
Dim ws As Worksheet
Set ws = Worksheets("6 Y")
ws.Cells(3, 17).Value = ComboBox2.Text
ws.Cells(4, 17).Value = Price.Text
ws.Cells(6, 19).Value = today.Text
ws.Cells(7, 24).Value = percentage.Text
ws.Cells(7, 25).Value = txtamount.Text
ws.Cells(1, 27).Value = ComboBoxpmtplan.Text
End Sub
Private Sub COMMRUN_Click()
Macro1
End Sub
只需按名称调用函数即可
Private Sub COMMRUN_Click()
Macro1
post_Click
End Sub
@rollstuhlfahrer哦哦,这个url是如此的书签化!警告:不要直接调用事件处理程序过程-处理程序意味着处理事件,而不是直接调用。正确的做法是从处理程序中提取实现,并在需要的地方调用逻辑。也就是说,这个答案是正确的,可以简化为“如何从标准类型库中调用
MsgBox
函数:通过键入其名称!”不起作用,我需要在运行宏之后发布数据两个函数的名称是什么,之后要调用哪个函数?