View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default inputbox error when clicking cancel

Sub SelectRange()
Dim UserRange As Range
On Error Resume Next
Set UserRange = Application.InputBox( _
prompt:="Please input or select a range", Type:=8)
On Error goto 0
if not userrange is nothing then
UserRange.Font.Bold = True
end if
End Sub

I have a little different take on this than Steve.
There are many many errors associated with the RefEdit control. Far more
than this error with Application.Inputbox. I would be more inclined to check
the sheet for a situation that uses the troublesome conditional formatting
and put up the inputbox when it isn't a problem.

--
Regards,
Tom Ogilvy


"ADK" wrote:

If someone uses this code, but clicks cancle on the inputbox you get a code
error. What cacode can be added to prevent this error?

Sub SelectRange()
Dim UserRange As Range
Set UserRange = Application.InputBox( _
prompt:="Please input or select a range", Type:=8)
UserRange.Font.Bold = True
End Sub