Object required.

  • Thread starter Thread starter y
  • Start date Start date
Y

y

Set rArea = Application.InputBox(prompt:="Select range:", Type:=8)
Set rXValues = Application.InputBox(prompt:="Select XValues:", Type:=8)
Set rYValues = Application.InputBox(prompt:="Select YValues:", Type:=8)


It worked fine.
Now it reports the error in subject to me.
Sometime VBA crashes on the 1st instruction, sometime on the 2nd.

I hope to translate correct the error message because I'm using the italian version of VBA.

Thanks, Alex.
 
Hi Alex

Did you declare the variables ? Did you account for invalid entries and
Cancel ?

This should take care of both:

Sub Test()
Dim rArea As Range
Dim rXValues As Range
Dim rYValues As Range
On Error Resume Next
Set rArea = Application.InputBox(prompt:="Select range:", Type:=8)
If rArea Is Nothing Then Exit Sub
Set rXValues = Application.InputBox(prompt:="Select XValues:", Type:=8)
If rXValues Is Nothing Then Exit Sub
Set rYValues = Application.InputBox(prompt:="Select YValues:", Type:=8)
If rYValues Is Nothing Then Exit Sub
End Sub

HTH. Best wishes Harald
 

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

Back
Top