Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following inputbox and need to trap erros
Set Rng= Application.InputBox(Msg1, Title1, Type:=8) where Rng is dimmed as an object 1) how do I trap the user response if they click cancel 2) how do i tarp the user response if the click Enter without selecting a range |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Does this help?
Sub TestIt() Dim Rng As Object ' On Error GoTo Bad_Rng Set Rng = Application.InputBox(Msg1, Title1, Type:=8) On Error GoTo 0 ' MsgBox "Got to here" Exit Sub ' Bad_Rng: MsgBox "Cancel button was pressed" End Sub If the user clicks enter and the box is blank, or has a badly formed range in it, then the InputBox Method itself displays a warning message and doesn't let the user get away with it. The only two ways for the user to get out are to enter a valid range, or to press Cancel. You can trap Cancel by doing what I did above. Eric |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'd probably do it this way
Sub TestIt() Dim Rng As Object ' Set Rng = Nothing On Error Resume Next Set Rng = Application.InputBox(Msg1, Title1, Type:=8) On Error GoTo 0 ' If Rng Is Nothing Then MsgBox ("No range was selected.") End If End Sub -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "egun" wrote: Does this help? Sub TestIt() Dim Rng As Object ' On Error GoTo Bad_Rng Set Rng = Application.InputBox(Msg1, Title1, Type:=8) On Error GoTo 0 ' MsgBox "Got to here" Exit Sub ' Bad_Rng: MsgBox "Cancel button was pressed" End Sub If the user clicks enter and the box is blank, or has a badly formed range in it, then the InputBox Method itself displays a warning message and doesn't let the user get away with it. The only two ways for the user to get out are to enter a valid range, or to press Cancel. You can trap Cancel by doing what I did above. Eric |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Application InputBox Type 8 Error | Excel Programming | |||
Application.InputBox | Excel Programming | |||
application.inputbox | Excel Programming | |||
Inputbox and Application.InputBox | Excel Programming | |||
application.inputbox | Excel Programming |