4 Replies - 922 Views - Last Post: 28 March 2013 - 10:28 PM Rate Topic: -----

#1 jassi2384  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-March 13

Runtime error 5

Posted 25 March 2013 - 04:20 AM

I am getting runtime error 5 on this code

Set s = _
Application.InputBox("Select the Range", _
Title:="Dell", Type:=8)

For Each cell In Range(s.Address)
slash = cell.Value
If slash = "" Then GoTo x
On Error GoTo x
dash = Left(slash, InStr(slash, Chr(44)) - 1)
If dash = "" Then
cell.Value = cell.Value
Else
End If
cell.Value = dash
x:
Next cell
End Sub

Is This A Good Question/Topic? 0
  • +

Replies To: Runtime error 5

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3479
  • View blog
  • Posts: 11,821
  • Joined: 12-December 12

Re: Runtime error 5

Posted 25 March 2013 - 04:26 AM

It would help us to help you if you displayed the full content of the error message and indicate which line it refers to in your posted code.

Please wrap your code in code-tags. It tells you how to do this directly in the area where you are typing your post; press the Preview button so that you can check how it looks.

I haven't examined your code as yet, but this line stands out:

cell.Value = cell.Value

??
and your use of Goto is.. icky..

This post has been edited by andrewsw: 25 March 2013 - 04:28 AM

Was This Post Helpful? 0
  • +
  • -

#3 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Runtime error 5

Posted 25 March 2013 - 09:16 PM

I looked up error 5 and it's Invalid Procedure Call. Doesn't happen very often; one way to get it is to try to call the SetFocus method on a text box that's been disabled. We'll need to know what line the error occurs on.

By the way, InputBox is not a method of the Application object.

This post has been edited by BobRodes: 25 March 2013 - 09:21 PM

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3479
  • View blog
  • Posts: 11,821
  • Joined: 12-December 12

Re: Runtime error 5

Posted 26 March 2013 - 12:22 AM

View PostBobRodes, on 26 March 2013 - 04:16 AM, said:

By the way, InputBox is not a method of the Application object.

This is Excel VBA, in which case there exists Application.InputBox() and Type:=8 allows the user to select a Range.
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Runtime error 5

Posted 28 March 2013 - 10:28 PM

Aha. Thanks for the explanation, Andrew.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1