LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Help with nested for loops

Hi

I am trying to write a macro to accomplish a task.

Here is the scenario:

From sheet1 to sheet20, there is a table in range A19:D30:



Apr-05 * * *
May-05 11 * 7
Jun-05 * 6 *
Jul-05 * * *
Aug-05 * * *
Sep-05 * * *
Oct-05 6 * 8
Nov-05 * 9 *
Dec-05 * * *
Jan-06 9 * *
Feb-06 * * *
Mar-06 * * *

In sheet21 I want to create 20 tables. All the Apr-05 rows will
create
the first table, May-05 rows will create the second table, so on and
so forth.


The code I have come up with is:


Sub myTables()
Dim RowNdx1 As Integer
Dim RowNdx2 As Integer
Dim RowNdx3 As Integer


For RowNdx1 = 1 To 20 Step 1
For RowNdx2 = 17 To 30 Step 1
For RowNdx3 = 1 To 240 Step 1
Sheets("sheet" & RowNdx1).Select
Rows(RowNdx2 & ":" & RowNdx2).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("sheet21").Select
Rows(RowNdx3 & ":" & RowNdx3).Select
ActiveSheet.Paste
Next RowNdx3
Next RowNdx2
Next RowNdx1


End Sub


This code runs and goes into an infinite loop. I am sure I have not
coded it correctly, but don't know where the mistake is.


Any help will be very appreciated.


Thanks

 
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
Help with nested for loops [email protected] Excel Discussion (Misc queries) 5 May 2nd 07 05:30 PM
Help with nested for loops [email protected] Excel Worksheet Functions 5 May 2nd 07 05:30 PM
Many Nested loops naterator Excel Programming 4 June 19th 06 10:43 PM
nested for loops and end for SandyR Excel Programming 3 October 6th 05 09:36 PM
Help on nested loops Jan Lukszo Excel Programming 1 July 29th 04 08:41 AM


All times are GMT +1. The time now is 06:38 AM.

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"