Solved

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

Posted on 2004-08-16
5
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

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 have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

739 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