Run time erroor 1004 Application defined or object defined error

Posted on 2004-04-26
Last Modified: 2008-02-01
Can any body help in refining the code
In a function dealing with Excel I'm getting runtime error 1004

My code is like this

If Excelo.Range("N24").Value = 0 Then
    Rop = 30
ElseIf Excelo.Range("N24").Value = 1 Then
    Rop = 31
ElseIf Excelo.Range("N24").Value > 1 Then
    If Excelo.Range("M" & Chr(Row)).Value <> "" Then
    Rop = Rop + 1
    End If
    Loop Until Excelo.Range("M" & Chr(Row)).Value = ""
End If

It is highlighting

 If Excelo.Range("M" & Chr(Row)).Value <> "" Then

I'm checking excel cells and if the cell cell is not empty The value of Rop should be increased

Thank You

Question by:LakshmanaRavula
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 43

Accepted Solution

TimCottee earned 500 total points
ID: 10923819
Hi LakshmanaRavula,

Rather than use the range object, use the cells property:

    If Excelo.Cells(13,Row).Value <> "" Then
    Rop = Rop + 1
    End If
    Loop Until Excelo.Cells(13,Row).Value = ""

Tim Cottee
Brainbench MVP for Visual Basic

Author Comment

ID: 10923871
Thank You Tim
It worked Out fine
But i had a question, In all my code I'm using range object
Does it makes any difference or problem else whare when I use Cells property for this particular part
LVL 43

Expert Comment

ID: 10924004

Not at all, you have to select the best object/property to do a specific task. Personally I don't like the range object because of this sort of thing though it has its place. The Cells property is in some ways much easier when you are coding as you don't have to build the range string and can easily do nested loops to get whole ranges and manipulate them.


Author Comment

ID: 10928296
Thank You Tim
For my next coding I will use cells property for the whole code
Thank You once again for a good tip to learn

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question