Solved

Run time erroor 1004 Application defined or object defined error

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

740 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