Solved

50 point question on Excel VBA Application defined or object defined error

Posted on 2004-08-16
5
186 Views
Last Modified: 2009-07-29
Please post comments in the original question at http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21095174.html

Sub CopyTraders()
    Dim Trader As String
    Dim r As Integer
    Dim r2 As Integer
    Dim ColCount As Integer
    Dim rng As Range
     Set rng = ActiveWorkbook.Sheets("layout").UsedRange
    r2 = 5  ''start printing in report at row (5)
    For r = 4 To rng.Rows.Count ''start reading from layout at row (4)
        If rng.Cells(r, 1).value <> "" Then
            Trader = rng.Cells(r, 1).value
           ---> Sheets("report").Cells(r2, ColCount + 2) = Trader             Error occurs in this statement
            ColCount = (ColCount + 1) Mod 4
            If ColCount = 0 Then
                r2 = r2 + 1
            End If
        End If
    Next r
    Sheets("report").Activate
End Sub
0
Comment
Question by:efarhat
5 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11810819
I haven't worked with Excel much but you can't just pull the "report" Sheet out of thin air...

...but I think it should be:

    ActiveWorkbook.Sheets("report").Cells(r2, ColCount + 2) = Trader

and
 
    ActiveWorkbook.Sheets("report").Activate

Idle_Mind
0
 

Author Comment

by:efarhat
ID: 11811036
Idle_Mind,

that didn't work.
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 20 total points
ID: 11811178
Have you tried

Sheets("report").Cells(r2, ColCount + 2).value  = Trader
0
 
LVL 81

Expert Comment

by:byundt
ID: 11817107
Essa,
I changed this question into a Pointer Question leading to your original question at in the Excel TA. I also refunded 30 of the 50 points in the original value of this question.
byundt--Excel TA Page Editor
0
 

Author Comment

by:efarhat
ID: 11833936
Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

920 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

16 Experts available now in Live!

Get 1:1 Help Now