Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default For index = 2 To Source.Rows.Count

For index = 2 To Source.Rows.Count

What does the 2 mean in this line
--
ca1358
  #2   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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" wrote in message
...
For index = 2 To Source.Rows.Count

What does the 2 mean in this line
--
ca1358





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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" wrote in message
...
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" wrote in message
...
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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count, Sum, Index,Match or other formula needed Nadine Excel Worksheet Functions 1 May 4th 10 09:01 PM
INDEX/MATCH automatic updates while source files are closed mariekek5 Excel Discussion (Misc queries) 5 June 8th 09 04:19 PM
Index/Match to get Count (from Subtotals) into a Table of Names ryguy7272 Excel Worksheet Functions 3 November 6th 08 12:58 AM
Using INDEX w/MATCH to get data from unsorted source Lynn Bales New Users to Excel 3 July 22nd 05 02:52 PM
find out line count source in vbe tom cang Excel Programming 0 November 26th 04 04:31 AM


All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"