通过1st命令发布数据后添加宏来运行

时间:2018-01-25 14:52:31

标签: 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.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 

1 个答案:

答案 0 :(得分:1)

您只需按名称调用该功能

即可
Private Sub COMMRUN_Click()
    Macro1
    post_Click
End Sub