+ Reply to Thread
Results 1 to 2 of 2

Debug: For,next does not start at specified row

  1. #1
    Registered User
    Join Date
    05-27-2013
    Location
    Middle, Nowhere
    MS-Off Ver
    Excel 2003
    Posts
    13

    Debug: For,next does not start at specified row

    I have the following code that when run starts at row 1 instead of 84. For the life of me I cannot figure out why this is so.

    Please Login or Register  to view this content.
    The odd things is, when I run my entire macro, it starts at row 84 and stops right there. It doesn't move on to the next row. So I'm stuck with only 1 miserly entry. My full code is as follows:

    Please Login or Register  to view this content.
    Anybody have any ideas?

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,689

    Re: Debug: For,next does not start at specified row

    Well, you didn't attach a workbook, so, ...
    --------------------------------
    Notice that the line j = Sheets("MasterList").Cells(Rows.Count, 4).End(xlUp).Row is inside your For i... loop; therefore, it will be re-initialized to the number of the last used row in Sheets("MasterList") column D each time your I-loop increments.

    Say, Sheets("Sheet1 (3)"), is using 200 rows and Masterlist is using 1200 rows. Then your i loop will increment from 84 to 200, and each time, j will be initialized to 1200. Notice, also that j is never incremented! Thus the lines:

    Sheets("MasterList").Cells(j + 1, 1).Value = Sheets("Sheet1 (3)").Cells(i, 3).Value
    Sheets("MasterList").Cells(j + 1, 2).Value = Sheets("Sheet1 (3)").Cells(i, 4).Value
    Sheets("MasterList").Cells(j + 1, 3).Value = Sheets("Sheet1 (3)").Cells(i, 5).Value


    will write in Masterlist row 1201 for each increment of i. J never changes it always points at row 1201 ( in this case).
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy variable amount of rows between Start and End to Start
    By EDo1981 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2013, 07:37 AM
  2. Replies: 0
    Last Post: 05-06-2006, 04:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1