View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Shawn[_10_] Shawn[_10_] is offline
external usenet poster
 
Posts: 2
Default Looping through a range

On Mon, 03 Oct 2005 15:38:26 -0400, Tom Ogilvy wrote:

should get your max value.

Sub ABC()
rw = 10
total = 0
Range("A1").Select
For i = 0 To 2
For j = 0 To 2
tempValue = ActiveCell.Offset(i, j)
For k = i + 1 To 2
For L = 0 To 2
tempValue2 = ActiveCell.Offset(k, L)
tempTotal = tempValue + tempValue2
If k < i Then
Cells(rw, 1) = ActiveCell.Offset(i, j)
Cells(rw, 2) = ActiveCell.Offset(k, L)
Cells(rw, 3) = tempTotal
rw = rw + 1
If tempTotal total Then total = tempTotal
End If
Next L
Next k
Next j
Next i

End Sub


Hi Tom,

Thank you for such a quick reply. I'll give the above code a try. It
didn't occur to me to use "if/then" statements like that.

Thanks again.

Shawn