Closed Thread
Results 1 to 6 of 6

For index = 2 To Source.Rows.Count

  1. #1
    ca1358
    Guest

    For index = 2 To Source.Rows.Count

    For index = 2 To Source.Rows.Count

    What does the 2 mean in this line
    --
    ca1358

  2. #2
    GB
    Guest

    RE: For index = 2 To Source.Rows.Count

    It means, that basically to start from Row 2 of the worksheet called Source
    and go until the last row of Source. If Source.Rows.Count is less than 2
    then the for loop is bypassed. If that function returns 2 then the for loop
    is run one time. The code between the first For and the "next for" related
    to this will be run the number of times given by the difference of
    Source.Rows.Count and 2. (No it can not be "undone" by a negative value. )


    "ca1358" wrote:

    > For index = 2 To Source.Rows.Count
    >
    > What does the 2 mean in this line
    > --
    > ca1358


  3. #3
    gwhenning
    Guest

    RE: For index = 2 To Source.Rows.Count

    It is the first number to start your count by. You are essentially counting
    from index to Source.rows.count index starts at 2 and is then incremented in
    the code that follows.

    "ca1358" wrote:

    > For index = 2 To Source.Rows.Count
    >
    > What does the 2 mean in this line
    > --
    > ca1358


  4. #4
    Bob Phillips
    Guest

    Re: For index = 2 To Source.Rows.Count

    Rows.Count will be 65536 for any sheet, including Source, unless it is not
    a worksheet, when it will error. So it will always run 65535 times, unless
    index gets incremented inside the loop.

    --

    HTH

    RP

    "GB" <[email protected]> wrote in message
    news:[email protected]...
    > It means, that basically to start from Row 2 of the worksheet called

    Source
    > and go until the last row of Source. If Source.Rows.Count is less than 2
    > then the for loop is bypassed. If that function returns 2 then the for

    loop
    > is run one time. The code between the first For and the "next for"

    related
    > to this will be run the number of times given by the difference of
    > Source.Rows.Count and 2. (No it can not be "undone" by a negative value.

    )
    >
    >
    > "ca1358" wrote:
    >
    > > For index = 2 To Source.Rows.Count
    > >
    > > What does the 2 mean in this line
    > > --
    > > ca1358




  5. #5
    Bob Phillips
    Guest

    Re: For index = 2 To Source.Rows.Count

    Running to the end of the rows seems superfluous, it should check for the
    end of the data to stop unnecessary iterations of the loop.

    --

    HTH

    RP

    "ca1358" <[email protected]> wrote in message
    news:[email protected]...
    > For index = 2 To Source.Rows.Count
    >
    > What does the 2 mean in this line
    > --
    > ca1358




  6. #6
    NickHK
    Guest

    Re: For index = 2 To Source.Rows.Count

    Bob,
    Unless the code is run in the upcoming Excel 12, which a limit of 1 million
    (?) rows.

    NickHK

    "Bob Phillips" <[email protected]> wrote in message
    news:%[email protected]...
    > Rows.Count will be 65536 for any sheet, including Source, unless it is

    not
    > a worksheet, when it will error. So it will always run 65535 times, unless
    > index gets incremented inside the loop.
    >
    > --
    >
    > HTH
    >
    > RP
    >
    > "GB" <[email protected]> wrote in message
    > news:[email protected]...
    > > It means, that basically to start from Row 2 of the worksheet called

    > Source
    > > and go until the last row of Source. If Source.Rows.Count is less than

    2
    > > then the for loop is bypassed. If that function returns 2 then the for

    > loop
    > > is run one time. The code between the first For and the "next for"

    > related
    > > to this will be run the number of times given by the difference of
    > > Source.Rows.Count and 2. (No it can not be "undone" by a negative

    value.
    > )
    > >
    > >
    > > "ca1358" wrote:
    > >
    > > > For index = 2 To Source.Rows.Count
    > > >
    > > > What does the 2 mean in this line
    > > > --
    > > > ca1358

    >
    >




Closed Thread

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