Sub 主程序()
Dim Rng
Set Rng = Rec
If Rng Is Nothing Then Exit Sub
End Sub
Function Rec()
Dim Rrng as range
On Error Resume Next
Set Rrng = Application.InputBox("选择区域", "选择", "A1", Type:=8)
If Rrng Is Nothing Then Err.Clear: Set Rec = Nothing: Exit Function
Set Rec = Rrng
End Function
利用子程序 on error resume next
来检查 是否按了取消
主程序 不受 on error resume next 不受影响
Dim Rng
Set Rng = Rec
If Rng Is Nothing Then Exit Sub
End Sub
Function Rec()
Dim Rrng as range
On Error Resume Next
Set Rrng = Application.InputBox("选择区域", "选择", "A1", Type:=8)
If Rrng Is Nothing Then Err.Clear: Set Rec = Nothing: Exit Function
Set Rec = Rrng
End Function
利用子程序 on error resume next
来检查 是否按了取消
主程序 不受 on error resume next 不受影响
