ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   [excel 97 vba ] Reading ranges into an array (https://www.excelbanter.com/excel-programming/281028-%5Bexcel-97-vba-%5D-reading-ranges-into-array.html)

steve

[excel 97 vba ] Reading ranges into an array
 
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

Tom Ogilvy

[excel 97 vba ] Reading ranges into an array
 
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


--
Regards,
Tom Ogilvy

"steve" wrote in message
...
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





All times are GMT +1. The time now is 12:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com