Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm looping through a named range looking for cells whose value matches a
criteria. For each of those cells that match, I want to assign the cells value to an "incremented" variable (Var1, Var2, Var3, etc.) Counter = 1 Set rng = range("myRange") 1 For each cell in rng 2 If cell.value = "whatever" 3 Var & counter = cell.value 4 End if 5 Next cell I cant get line 3 to work (Var1, Var2, Var3) Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You should be using arrays if you want to do that kind of thing. You are best
off reading up on arrays in vba. "David Looney" wrote: I'm looping through a named range looking for cells whose value matches a criteria. For each of those cells that match, I want to assign the cells value to an "incremented" variable (Var1, Var2, Var3, etc.) Counter = 1 Set rng = range("myRange") 1 For each cell in rng 2 If cell.value = "whatever" 3 Var & counter = cell.value 4 End if 5 Next cell I cant get line 3 to work (Var1, Var2, Var3) Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dave, Let me know if this helps:
Dim strVar(20) As String Set rng = Range("myRange") For Each cell In rng If cell.value = "whatever" strVar(i) = cell.Value i = i + 1 End If Next cell "Blue Aardvark" wrote: You should be using arrays if you want to do that kind of thing. You are best off reading up on arrays in vba. "David Looney" wrote: I'm looping through a named range looking for cells whose value matches a criteria. For each of those cells that match, I want to assign the cells value to an "incremented" variable (Var1, Var2, Var3, etc.) Counter = 1 Set rng = range("myRange") 1 For each cell in rng 2 If cell.value = "whatever" 3 Var & counter = cell.value 4 End if 5 Next cell I cant get line 3 to work (Var1, Var2, Var3) Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
incremented numbering | Excel Discussion (Misc queries) | |||
How can a single cell be incremented? i.e. N=N+1 | Excel Discussion (Misc queries) | |||
setting object variable | Excel Programming | |||
Setting variable = to sheet name | Excel Programming | |||
setting a range variable equal to the value of a string variable | Excel Programming |