Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA - changing variables during a loop
Hi,
I am trying to write a loop code using the For...Next statements, for counter running from 1 To 100. However, I want to change the value o two of the variables (there are 5 used in the procedure) after counte = 10, then again at 20, 30, and so on. I have not been able to figure out how to do this without repeating th code with the new value for the variable re-defined. Has anyone got any ideas of how to overcome this problem? Cheer -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA - changing variables during a loop
On Mon, 5 Jul 2004 02:13:34 -0500, ellis_x
wrote: Hi, I am trying to write a loop code using the For...Next statements, for a counter running from 1 To 100. However, I want to change the value of two of the variables (there are 5 used in the procedure) after counter = 10, then again at 20, 30, and so on. I have not been able to figure out how to do this without repeating the code with the new value for the variable re-defined. Has anyone got any ideas of how to overcome this problem? Cheers If the same thing always happens to those variables (for example, you always add 1 or something) then a simple if statement should do it: If (0 = counterVariable Mod 10) Then 'make changes here End If If it's a different action each time, then try select case: Select Case counterVariable Case 10 'make changes here Case 20 'make changes here Case 30 'make changes here [etc.] End Select -- auric underscore underscore at hotmail dot com ***** You can't exchange pleasantries with an attractive woman and feel entirely like a stranger. -- Isaac Asimov (Prelude to Foundation) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA - changing variables during a loop
for i=1 to 100
if i mod 10 = 0 then j=1 next keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool ellis_x wrote: Hi, I am trying to write a loop code using the For...Next statements, for a counter running from 1 To 100. However, I want to change the value of two of the variables (there are 5 used in the procedure) after counter = 10, then again at 20, 30, and so on. I have not been able to figure out how to do this without repeating the code with the new value for the variable re-defined. Has anyone got any ideas of how to overcome this problem? Cheers --- Message posted from http://www.ExcelForum.com/ |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA - changing variables during a loop
For i = 10 To 100 Step 10
.... Next ??? -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "ellis_x " wrote in message ... Hi, I am trying to write a loop code using the For...Next statements, for a counter running from 1 To 100. However, I want to change the value of two of the variables (there are 5 used in the procedure) after counter = 10, then again at 20, 30, and so on. I have not been able to figure out how to do this without repeating the code with the new value for the variable re-defined. Has anyone got any ideas of how to overcome this problem? Cheers --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
finding the results of changing 4 variables | Excel Discussion (Misc queries) | |||
Setting Multiple Variables with a loop | Excel Discussion (Misc queries) | |||
Changing the values of variables | Excel Programming | |||
Loop for changing cell formatting | Excel Programming | |||
Changing objects on other Worksheets with Variables | Excel Programming |