ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   nested while not working any more... (https://www.excelbanter.com/excel-programming/371190-nested-while-not-working-any-more.html)

criminalspeed

nested while not working any more...
 

This works in Excel 2002, but fails at the second "while" in Excel
2003....


Range("n50").Select
target = -3
j = 12
K = 36
Cells(j, 1).Select
Reading = ActiveCell
Cells(j, 4).Select
ActiveCell.FormulaR1C1 = Reading
Cells(j, 1).Select
While ((target <= -2.5) And (j < 500))

While (((Reading - target) < 0) And (Not (Reading = "")))
j = j + 1
Cells(j, 1).Select
Reading = ActiveCell
Cells(j, 3).Select
ActiveCell.FormulaR1C1 = Reading
Cells(j, 2).Select
CLD = ActiveCell
Cells(j, 1).Select

Wend
Cells(K, 18).Select
ActiveCell.FormulaR1C1 = CLD
K = K + 1
target = target + 1
j = 12
Wend


________________________________________________
TIA,
Crim


--
criminalspeed
------------------------------------------------------------------------
criminalspeed's Profile: http://www.excelforum.com/member.php...o&userid=37909
View this thread: http://www.excelforum.com/showthread...hreadid=574383


Tim Williams

nested while not working any more...
 
Error message?

--
Tim Williams
Palo Alto, CA


"criminalspeed" wrote in message
news:criminalspeed.2cyld5_1156279511.7615@excelfor um-nospam.com...

This works in Excel 2002, but fails at the second "while" in Excel
2003....


Range("n50").Select
target = -3
j = 12
K = 36
Cells(j, 1).Select
Reading = ActiveCell
Cells(j, 4).Select
ActiveCell.FormulaR1C1 = Reading
Cells(j, 1).Select
While ((target <= -2.5) And (j < 500))

While (((Reading - target) < 0) And (Not (Reading = "")))
j = j + 1
Cells(j, 1).Select
Reading = ActiveCell
Cells(j, 3).Select
ActiveCell.FormulaR1C1 = Reading
Cells(j, 2).Select
CLD = ActiveCell
Cells(j, 1).Select

Wend
Cells(K, 18).Select
ActiveCell.FormulaR1C1 = CLD
K = K + 1
target = target + 1
j = 12
Wend


________________________________________________
TIA,
Crim


--
criminalspeed
------------------------------------------------------------------------
criminalspeed's Profile: http://www.excelforum.com/member.php...o&userid=37909
View this thread: http://www.excelforum.com/showthread...hreadid=574383





All times are GMT +1. The time now is 11:25 AM.

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