Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple problem refering to variable in For ... Next loop ...
All,
I hate having to ask this 101 question, but here it goes: I have the following code in a function: c1 = Array(1, 2, 3) c2 = Array(100, 200, 300) r1 = 6 r2 = 600 For n = 1 To 2 If r? < Application.WorksheetFunction.Sum(c?) Then ... do this ... Else ... do that ... End If Next n I want to pass the value for r1 and c1 to the expression in the If statement the first time through the loop (n=1), and the value for r2 and c2 to the expression the second time through the loop (n=2), etc, but I cannot figure out the syntax to replace r? and c? with. thanks Chris |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple problem refering to variable in For ... Next loop ...
Sub tester5()
Dim c(1 To 2) Dim r(1 To 2) Dim n As Long c(1) = Array(1, 2, 3) c(2) = Array(100, 200, 300) r(1) = 6 r(2) = 600 For n = 1 To 2 If r(n) < Application.WorksheetFunction.Sum(c(n)) Then Debug.Print n, r(n), Application.WorksheetFunction.Sum(c(n)) Else Debug.Print n, r(n), Application.WorksheetFunction.Sum(c(n)) End If Next n End Sub Regards, Tom Ogilvy Chris wrote in message ... All, I hate having to ask this 101 question, but here it goes: I have the following code in a function: c1 = Array(1, 2, 3) c2 = Array(100, 200, 300) r1 = 6 r2 = 600 For n = 1 To 2 If r? < Application.WorksheetFunction.Sum(c?) Then ... do this ... Else ... do that ... End If Next n I want to pass the value for r1 and c1 to the expression in the If statement the first time through the loop (n=1), and the value for r2 and c2 to the expression the second time through the loop (n=2), etc, but I cannot figure out the syntax to replace r? and c? with. thanks Chris |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
simple loop needed please | Excel Discussion (Misc queries) | |||
Loop with variable name? | Excel Discussion (Misc queries) | |||
I need a simple loop with a 4+ row added in. | Excel Discussion (Misc queries) | |||
Insert Variable Number of Rows; With Loop | Excel Worksheet Functions | |||
Loop Macro a variable number of times | Excel Discussion (Misc queries) |