Link to home
Start Free TrialLog in
Avatar of LakshmanaRavula
LakshmanaRavula

asked on

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

 
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LakshmanaRavula
LakshmanaRavula

ASKER

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
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.
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