ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User input as a range. What am I doing wrong? (https://www.excelbanter.com/excel-programming/314616-user-input-range-what-am-i-doing-wrong.html)

Irada Shamilova

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

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

--
Irada Shamilov
-----------------------------------------------------------------------
Irada Shamilova's Profile: http://www.excelforum.com/member.php...fo&userid=1228
View this thread: http://www.excelforum.com/showthread.php?threadid=27209


Frank Kabel

User input as a range. What am I doing wrong?
 
Hi
your code works for me. I only get this error if I cancel the inputbox. and
this is easily solved if you use
on error resume next (remove the apostrophe before this statement)

"Irada Shamilova" wrote:


Hi!

I have found here the hint on Application.Inputbox(type:=8) & copied
the whole VBA code to try it. But I keep getting run-time error 424
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.
Irada


--
Irada Shamilova
------------------------------------------------------------------------
Irada Shamilova's Profile: http://www.excelforum.com/member.php...o&userid=12286
View this thread: http://www.excelforum.com/showthread...hreadid=272097




All times are GMT +1. The time now is 02:24 PM.

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