Array/Matrix
Hi
Here is some code.. However you can accomplish this more succintly by just
copying and pasting in code.
Public Function CopyFromOneSheetToAnother(ByVal sOne$, ByVal sOther$) As
Boolean
Dim aValues() As Variant
Dim i%, lNumRows&
Dim wsOne As Worksheet
Dim wsOther As Worksheet
Set wsOne = ThisWorkbook.Worksheets(sOne)
Set wsOther = ThisWorkbook.Worksheets(sOther)
lNumRows = wsOne.Cells.SpecialCells(xlCellTypeLastCell).Row
ReDim aValues(1 To lNumRows, 1 To 3)
For i = 1 To wsOne.Cells.SpecialCells(xlCellTypeLastCell).Row
aValues(i, 1) = wsOne.Cells(i, 1).Value
aValues(i, 2) = wsOne.Cells(i, 2).Value
aValues(i, 3) = wsOne.Cells(i, 3).Value
Next i
With wsOther
With .Range(.Cells(1, 1), .Cells(lNumRows, 3))
.Value = aValues
End With
End With
End Function
"Egon" wrote:
I need help setting up an array to read data into.
I would like to read data from 3 columns on one sheet into an array and
then copy that information into another sheet.
The Array/Matrix will be 3 columns wide, but the number of rows will
need to be dynamic.
Can anyone help?
TIA
E
|