[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-08-16
5
Medium Priority
?
196 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 86

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 80 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 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…
Suggested Courses

829 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