#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default InputBox

Hi
I have the following inputbox which returns a range selected by the user.

Set rRange = Application.InputBox(Prompt:="Please select any entry within "
_
& vbCrLf & "the row you would like to amend.", _
Title:="Select a row", Type:=8)

If however the user selects nothing and then clicks ok, an error box pops
up:-
"The formula you have typed contains an error etc".
Is it possible to have an alternative message box pop up which
would say something like - "You have not made a selection, please
try again!."
I could then redirect to the inputbox, by way of a goto.

I hope I am making sense.

Sandy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default InputBox

Sandy,
try this:

Sub RangeData()
Dim rRange As Range

On Error Resume Next

Application.DisplayAlerts = False

Set rRange = Application.InputBox _
(Prompt:="Please select any entry within " _
& vbCrLf & "the row you would like to amend.", _
Title:="Select a row", Type:=8)


On Error GoTo 0

Application.DisplayAlerts = True

If rRange Is Nothing Then

Debug.Print "cancelled"

Exit Sub

Else

rRange.Value = "OK"

End If

End Sub

Note the use of both, On Error Resume Next and Application.DisplayAlerts =
False. These stop Excel from trying to handle any bad input from the user, or
if they Cancel.

Hope helpful
--
jb


"Sandy" wrote:

Hi
I have the following inputbox which returns a range selected by the user.

Set rRange = Application.InputBox(Prompt:="Please select any entry within "
_
& vbCrLf & "the row you would like to amend.", _
Title:="Select a row", Type:=8)

If however the user selects nothing and then clicks ok, an error box pops
up:-
"The formula you have typed contains an error etc".
Is it possible to have an alternative message box pop up which
would say something like - "You have not made a selection, please
try again!."
I could then redirect to the inputbox, by way of a goto.

I hope I am making sense.

Sandy


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
InputBox James8309 Excel Programming 2 June 17th 08 08:02 AM
Need InputBox Help Dan Brimley Excel Programming 0 May 24th 07 11:48 PM
Inputbox help... ChrisMattock[_11_] Excel Programming 3 May 12th 06 02:21 PM
Inputbox and Application.InputBox Maria[_7_] Excel Programming 1 September 20th 04 11:36 AM
inputbox defj Excel Programming 4 November 26th 03 10:25 PM


All times are GMT +1. The time now is 12:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"