User input as a range. What am I doing wrong?

I

Irada Shamilova

Hi!

I have found here the hint on Application.Inputbox(type:=8) & copie
the whole VBA code to try it. But I keep getting run-time error 42
message that Object is required. What is that I'm doing wrong?

Sub testme()

Dim rng As Range
'On Error Resume Next
Set rng = Application.InputBox("Select a Range..", Type:=8)
On Error GoTo 0
If rng Is Nothing Then
Exit Sub 'cancelled
Else
MsgBox rng.Address
End If
End Sub

Thanks in advance.
Irad
 
G

Guest

Hi
your code works for me. I only get this error if I cancel the inputbox. and
this is easily solved if you use
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top