Solved

Run time erroor 1004 Application defined or object defined error

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB error "Type mismatch" 2 53
Looking for VB6 code to read SQL table export it to ascii 8 38
How to Add / Edit Windows Menu 4 59
Send outlook email from VBS Script 2 28
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

815 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

12 Experts available now in Live!

Get 1:1 Help Now