Solved

Run time erroor 1004 Application defined or object defined error

Posted on 2004-04-26
4
2,112 Views
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
    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

 
0
Comment
Question by:LakshmanaRavula
  • 2
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 10923819
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
 

Author Comment

by:LakshmanaRavula
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
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 10924004
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
 

Author Comment

by:LakshmanaRavula
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
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now