Run time erroor 1004 Application defined or object defined error

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
    Do
    If Excelo.Range("M" & Chr(Row)).Value <> "" Then
    Rop = Rop + 1
    Else
    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

 
LakshmanaRavulaAsked:
Who is Participating?
 
TimCotteeConnect With a Mentor Head of Software ServicesCommented:
Hi LakshmanaRavula,

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

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

Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LakshmanaRavulaAuthor Commented:
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
0
 
TimCotteeHead of Software ServicesCommented:
LakshmanaRavula,

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.

Tim.
0
 
LakshmanaRavulaAuthor Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.