Solved

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

Posted on 2004-08-16
5
185 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
Comment Utility
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
Comment Utility
Idle_Mind,

that didn't work.
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 20 total points
Comment Utility
Have you tried

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

Expert Comment

by:byundt
Comment Utility
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
Comment Utility
Thanks.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 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…

771 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

9 Experts available now in Live!

Get 1:1 Help Now