Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Setting Multiple Variables with a loop | Excel Discussion (Misc queries) | |||
Non Static Variables in a For...Next Loop | Excel Programming | |||
Is it possible to create variables in a loop.. | Excel Programming | |||
Write variables from a loop, once only | Excel Programming | |||
Excel VBA - changing variables during a loop | Excel Programming |