我正在创建一个用户界面,用户点击工作表上的“单击以选择”按钮,然后调用并运行模块1到某个点,存储信息,暂停模块。模块1应该只在用户单击工作表上的提交按钮后继续运行。
UPDATE !!
它不仅仅是1个模块。它实际上有6个模块。其中,提交按钮必须继续,暂停/停止。无论如何,我可以将提交按钮链接到6个不同的模块吗?
Sub FlowRate()
Set chwflow_rate1 = Application.InputBox("Please select 1st cell with
Chilled Water Flowrate.", Type:=8)
Range(chwflow_rate1, chwflow_rate1.Offset(20159)).Select
Selection.Copy
' Program pause until user clicks submit button
' user click submit, program continues
Workbooks(1).Activate
Sheets("Data").Activate
Range("C8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.EntireColumn.Offset(0, 1).Insert
With ActiveSheet
For I = 7 To Cells(.Rows.Count, "C").End(xlUp).Row
aSplit = Split(Cells(I, "C"), " ", 8)
Cells(I, "C") = aSplit(0)
Cells(I, "D") = aSplit(1)
Next I
End With
Range("D8").Select
ActiveCell.EntireColumn.Delete
End Sub
答案 0 :(得分:1)
将功能拆分为两个单独的过程,并将提交按钮链接到FlowRateSubmit()。
Sub FlowRate()
Set chwflow_rate1 = Application.InputBox("Please select 1st cell with
Chilled Water Flowrate.", Type:=8)
Range(chwflow_rate1, chwflow_rate1.Offset(20159)).Select
Selection.Copy
End Sub
Sub FlowRateSubmit()
' Program pause until user clicks submit button
' user click submit, program continues
Workbooks(1).Activate
Sheets("Data").Activate
Range("C8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.EntireColumn.Offset(0, 1).Insert
With ActiveSheet
For I = 7 To Cells(.Rows.Count, "C").End(xlUp).Row
aSplit = Split(Cells(I, "C"), " ", 8)
Cells(I, "C") = aSplit(0)
Cells(I, "D") = aSplit(1)
Next I
End With
Range("D8").Select
ActiveCell.EntireColumn.Delete
End Sub