View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Die_Another_Day Die_Another_Day is offline
external usenet poster
 
Posts: 644
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)
If UserRange is Nothing then Exit Sub
UserRange.Font.Bold = True
On error Goto 0
End Sub

Charles Chickering
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