[excel 97 vba ] Reading ranges into an array

S

steve

Hello

Does anyone know if there is an elegant way to do the
following

read in a range from excel
copy values into an array
....
copy array to an output range

If some knows a good tutorial on arrays and range
manipulation that would be excellent.

So far I have to do a lot of looping and can't cannot help
feeling that I have reinvented the wheel so to speak.
Perhaps this is the only option in Excel 97..

thanks

Steve
 
T

Tom Ogilvy

Sub doArrays()
Dim varr As Variant
Dim numrows As Long
Dim numcols As Long
numrows = 3
numcols = 2
varr = Worksheets("Sheet1").Range("B9"). _
Resize(numrows, numcols).Value
For i = LBound(varr, 1) To UBound(varr, 1)
For j = LBound(varr, 2) To UBound(varr, 2)
MsgBox "varr(" & i & ", " & j & ")= " & varr(i, j)
Next
Next
Worksheets("Sheet3").Range("Z11"). _
Resize(numrows, numcols).Value = varr
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top