Results 1 to 6 of 6

A Loop does not loop throught. It stops after two cells.

Threaded View

AB33 A Loop does not loop... 09-14-2012, 07:54 AM
TMS Re: A Loop does not loop... 09-14-2012, 08:24 AM
AB33 Re: A Loop does not loop... 09-14-2012, 09:30 AM
TMS Re: A Loop does not loop... 09-14-2012, 09:55 AM
AB33 Re: A Loop does not loop... 09-14-2012, 10:20 AM
TMS Re: A Loop does not loop... 09-14-2012, 01:14 PM
  1. #1
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    A Loop does not loop throught. It stops after two cells.

    I have relly got weird problem with the attached sheet. I set up a last row and try to loop through from 1 to last row. For some unknow reason, the last row shows the correct result,but when it loops throught, instead of looping from 1 to 24, the loop stops at 1, or 2. To test my syntax, I set up a different module and tests it using msgboxes. The magboxes show the corrrect result,but if I use the same syntax on the actual sheet, the loop stops at 1, or 2.

    With Worksheets("Sheet1")
        LR2 = .Cells(.Rows.Count, 2).End(xlUp).Row
         For Y = 1 To LR2
         MsgBox Y
    The last row, ie LR2 is 24, but when it loops from 1 to LR2, instead of giving the result of 1 to 24, I have got 1 to 1.
    I am sure, There is an error on the above line, but having done a test, I am unable to see it. Please a person with eye for details help.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

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