Runtime Error 424 -- Object Required

Juggler_IN

Active Member
Joined
Nov 19, 2014
Messages
349
Office Version
  1. 2003 or older
Platform
  1. Windows
I have the following code through which I am passing the address of the selected cell to WkRNG variable.

Now, when I click a cell and press okay all goes fine. But, if I press ESC (without any input), I get the runtime 424 error.

Code:
    Dim WkSht As Worksheet, WkRNG As Range, rCell As Range
    Set WkSht = ActiveSheet

    Range("A1").Select

    WkSht.Select
    ' The user must select the first cell with a value in the column with values for the plot.
    Set WkRNG = Application.InputBox(prompt:="Select the cell with the first value (in " & _
                                             "the column with data for the plot):", Type:=8)

    ' If the user cancelled.
    If WkRNG Is Nothing Then Exit Sub

Any solution? whereby I can exit the box without runtime error when there is no input.
 
Last edited:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Code:
  On Error Resume Next
  Set WkRNG = Application.InputBox(...)
  On Error GoTo 0
  If WkRNG Is Nothing Then Exit Sub
 
Upvote 0

Forum statistics

Threads
1,215,107
Messages
6,123,126
Members
449,097
Latest member
mlckr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top