Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Final Value, For / Next Loop

Nothing is mentioned in the remarks for the For / Next Loop about NOT
being able to change the final value of the counter.

In my application I have a set number of rows per "page" in a manual, and I
want to skip the first row of each page.

I have proven that the following code does NOT work when crossing
this "first" row boundary. I've coded a work around using do until ....
by maybe I'm doing something wrong. Any comments?

For XX = TargetRow To FRow
If XX Mod RteRowsPPg < 1 Then Cells(XX, RigCol).Interior.ColorIndex =
Salmon Else FRow = FRow + 1
Next XX ' note Salmon is set to a number via a Const statement.

Thanks,
Neal Z.



--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Final Value, For / Next Loop

What I think I would do would be to use two loops: one to loop through the
"pages" and the other to loop through the rows:
' I would have code here to calculate PageCount, the number of pages; I assume
' you already know the RowsPerPage
For i = 1 to PageCount
For j = 2 to RowsPerPage ' skips the first row on the "page"
'Note how I use i and j to calculate the current row:
Cells(((i - 1) * RowsPerPage) + j, RigCol).Interior.ColorIndex - Salmon
Next j
Next i

--
- K Dales


"Neal Zimm" wrote:

Nothing is mentioned in the remarks for the For / Next Loop about NOT
being able to change the final value of the counter.

In my application I have a set number of rows per "page" in a manual, and I
want to skip the first row of each page.

I have proven that the following code does NOT work when crossing
this "first" row boundary. I've coded a work around using do until ....
by maybe I'm doing something wrong. Any comments?

For XX = TargetRow To FRow
If XX Mod RteRowsPPg < 1 Then Cells(XX, RigCol).Interior.ColorIndex =
Salmon Else FRow = FRow + 1
Next XX ' note Salmon is set to a number via a Const statement.

Thanks,
Neal Z.



--
Neal Z

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Final Value, For / Next Loop

Thanks KD,
I'll use your method in other areas of the macro where all or many pages
have to processed.
My example is for a specific need, where by your answer I think you
confirmed the question about NOT being to modify the value of the 'to'
variable in the for statement while the loop is executing.
--
Neal Z


"Neal Zimm" wrote:

Nothing is mentioned in the remarks for the For / Next Loop about NOT
being able to change the final value of the counter.

In my application I have a set number of rows per "page" in a manual, and I
want to skip the first row of each page.

I have proven that the following code does NOT work when crossing
this "first" row boundary. I've coded a work around using do until ....
by maybe I'm doing something wrong. Any comments?

For XX = TargetRow To FRow
If XX Mod RteRowsPPg < 1 Then Cells(XX, RigCol).Interior.ColorIndex =
Salmon Else FRow = FRow + 1
Next XX ' note Salmon is set to a number via a Const statement.

Thanks,
Neal Z.



--
Neal Z

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
final return! via135 Excel Worksheet Functions 5 January 11th 08 11:00 AM
Macro - Final ciba1234 Excel Programming 1 September 15th 05 09:14 PM
Final Question Himszy Excel Programming 3 December 31st 04 08:30 PM
some final help rbekka33[_19_] Excel Programming 1 September 23rd 04 01:19 PM
Help Finding the Final Row No Name Excel Programming 7 May 21st 04 03:13 AM


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

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

About Us

"It's about Microsoft Excel"