![]() |
evaluate and variables and loop...
I haven't used "Evaluate" very much. I saw an article on it and
decided to try so I didn't have to use formulas in my spreadsheet to get things done. But now I'm running into issues with it. Hopefully someone can help me. Can I use a variable in an evaluation? my code: Dim people As Integer Dim i As Integer Dim x As Boolean Set rng = [lst] Set rng1 = rng.Offset(0, 1) Set rng2 = rng1.Offset(0, 1) rng2.Formula = "=rand()" people = rng2.Rows.Count i = 1 For i = 1 To people Cells(i, 4).Value = "=IF(A" & i & "=B" & i & ",True,False)" Next i ' this is my problem line: x = [IF((COUNTIF(D:D,"False"))={this is where I want my variable "people" to go},False,True)] Do Until x = True 'msgbox x rng1.Resize(, 3).Sort Key1:=rng2 Loop My second problem is that even if I just type the value I want (in this case 17) into the evaluation formula, my loop lasts forever. Even if the formula for x = True... My syntax must be wrong. I've been looking at some heavy code for about 10 days straight and am probably missing something simple again. Thanks, Rob |
evaluate and variables and loop...
OK, using the message box, I found that x is always False and the loop
runs forever... SO, my problem is truly the evaluation statement. x = [IF((COUNTIF(D:D,"False"))={this is where I want my variable "people" to go},False,True)] OKROB wrote: I haven't used "Evaluate" very much. I saw an article on it and decided to try so I didn't have to use formulas in my spreadsheet to get things done. But now I'm running into issues with it. Hopefully someone can help me. Can I use a variable in an evaluation? my code: Dim people As Integer Dim i As Integer Dim x As Boolean Set rng = [lst] Set rng1 = rng.Offset(0, 1) Set rng2 = rng1.Offset(0, 1) rng2.Formula = "=rand()" people = rng2.Rows.Count i = 1 For i = 1 To people Cells(i, 4).Value = "=IF(A" & i & "=B" & i & ",True,False)" Next i ' this is my problem line: x = [IF((COUNTIF(D:D,"False"))={this is where I want my variable "people" to go},False,True)] Do Until x = True 'msgbox x rng1.Resize(, 3).Sort Key1:=rng2 Loop My second problem is that even if I just type the value I want (in this case 17) into the evaluation formula, my loop lasts forever. Even if the formula for x = True... My syntax must be wrong. I've been looking at some heavy code for about 10 days straight and am probably missing something simple again. Thanks, Rob |
All times are GMT +1. The time now is 01:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com