Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,562
- Office Version
- 365
- 2016
- Platform
- Windows
My apologies for the title ... I'm not sure how to best sum up the issue with the proper terminology.
Without getting into the details of a solution, let me explain the situation I got myself into.
I have an application that creates an initial dataset. Lets say the project created a range of 21 rows. eg. nRows = 21
The application then loops (For/Next) through each of the rows of the dataset. ie For i = 1 to nRows in the dataset
Within the loop, code will analyze, compile and adjust this data. AT one point in the analysis, if a certain scenario exists, the code will add rows to the dataset. The dataset has grown from the original 21 rows to 24 with the addition of 3 more rows added by the routine. With each additional row I have been adding one to nRows.
The problem I'm running into as you all will likely see, is my loop will no longer loop through the entire dataset as it has grown. Although nRows has increased to 24, the loop will only loop through the original 21 rows assigned at the establishment of the loop.
My question is, before I ask how, can this situation be easily overcome? What is the best way to adjust a loop to accommodate it's growth? Perhaps an For/Next loop isn't the best choice.
Without getting into the details of a solution, let me explain the situation I got myself into.
I have an application that creates an initial dataset. Lets say the project created a range of 21 rows. eg. nRows = 21
The application then loops (For/Next) through each of the rows of the dataset. ie For i = 1 to nRows in the dataset
Within the loop, code will analyze, compile and adjust this data. AT one point in the analysis, if a certain scenario exists, the code will add rows to the dataset. The dataset has grown from the original 21 rows to 24 with the addition of 3 more rows added by the routine. With each additional row I have been adding one to nRows.
The problem I'm running into as you all will likely see, is my loop will no longer loop through the entire dataset as it has grown. Although nRows has increased to 24, the loop will only loop through the original 21 rows assigned at the establishment of the loop.
My question is, before I ask how, can this situation be easily overcome? What is the best way to adjust a loop to accommodate it's growth? Perhaps an For/Next loop isn't the best choice.