View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Using Arrays to Fill a Range

Sub TestALt()
Dim i, j, myX, myY, myZ
Dim idx As Long
Dim aryData(1 To 441, 1 To 3)
i = 10
j = 10
idx = 1
For myX = -i To i
For myY = -j To j
aryData(idx, 1) = myX
aryData(idx, 2) = myY
aryData(idx, 3) = i + j
idx = idx + 1
Next myY
Next myX
ActiveCell.Resize(441, 3) = aryData
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"nenad" wrote in message
ps.com...
Here is a type of code that I am using now. myX, myY and myZ are
filled 'by force' down to rows and is extremely slow. How to make a
code to insert these values into an array and then transfer the
contents of the array to the range?

Code:
 Sub Test()

    i = 10
    j = 10
    For myX = -i To i
        For myY = -j To j
            myZ = i + j
            ActiveCell.Value = myX
            ActiveCell.Offset(0, 1).Value = myY
            ActiveCell.Offset(0, 2).Value = myZ
            Cells(ActiveCell.RoW + 1, 1).Select
        Next myY
    Next myX
 End Sub