ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Object required. (https://www.excelbanter.com/excel-programming/294751-object-required.html)

y

Object required.
 
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.


Harald Staff

Object required.
 
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

"y" skrev i melding ...
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.





All times are GMT +1. The time now is 10:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com