ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Nested For..Next Qn. (https://www.excelbanter.com/excel-programming/364791-nested-next-qn.html)

Stella

Nested For..Next Qn.
 
Is it possible to force a change to a parameter in nested loops?

In other words, I want to compare two cells in different rows and, depending
on the result, restart the loop counter from a different position.

e.g.:-

For x = 1 to 99
For y = x+1 to 100
If Cells(x,1) = Cells(y,1) Then
Cells(y,1) = Range("y,3")
x = 1
next y
next x

The compare could be true at , say , x= 3 and y = 30 but I need the test to
recommence at x= 1 to take into account the new value in Cells(y,1)

I've tried the above plus a few variations but without success


TIA
Stella



[email protected]

Nested For..Next Qn.
 
apart from missing an END IF you have code that should work OK in terms
of resetting X

Stella wrote:
Is it possible to force a change to a parameter in nested loops?

In other words, I want to compare two cells in different rows and, depending
on the result, restart the loop counter from a different position.

e.g.:-

For x = 1 to 99
For y = x+1 to 100
If Cells(x,1) = Cells(y,1) Then
Cells(y,1) = Range("y,3")
x = 1
next y
next x

The compare could be true at , say , x= 3 and y = 30 but I need the test to
recommence at x= 1 to take into account the new value in Cells(y,1)

I've tried the above plus a few variations but without success


TIA
Stella




All times are GMT +1. The time now is 01:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com