G
gimme_this_gimme_that
I'd like to get this code to enter "2,4,7" in A1:C10.
A requirement is that their be only a single assignment into the
worksheet.
DON{T POST A SOLUTION WHERE "2,4,7" IS ENTERED INTO THE WORKSHEET ON
EACH ITERATION.
If this example can be made to work the next step would be to time and
compare against similar code that assigns a row at a time and then a
cell at a time.
Thanks.
Sub N_By_M()
Dim x() As Variant, i As Long, startTime As Single, endTime As
Single
Dim b As Workbook
Dim s As Worksheet
Dim r As Range
ReDim x(10)
Const maxLoop As Long = 10
startTime = Timer
For i = 1 To maxLoop
ReDim Preserve x(1 To i)
x(i) = Array(2, 4, 7)
Next i
Set b = ActiveWorkbook
Set s = b.Sheets("Sheet1")
Set r = s.Range("A1:C10")
r.Value = Application.Transpose(x)
endTime = Timer
MsgBox endTime - startTime
End Sub
A requirement is that their be only a single assignment into the
worksheet.
DON{T POST A SOLUTION WHERE "2,4,7" IS ENTERED INTO THE WORKSHEET ON
EACH ITERATION.
If this example can be made to work the next step would be to time and
compare against similar code that assigns a row at a time and then a
cell at a time.
Thanks.
Sub N_By_M()
Dim x() As Variant, i As Long, startTime As Single, endTime As
Single
Dim b As Workbook
Dim s As Worksheet
Dim r As Range
ReDim x(10)
Const maxLoop As Long = 10
startTime = Timer
For i = 1 To maxLoop
ReDim Preserve x(1 To i)
x(i) = Array(2, 4, 7)
Next i
Set b = ActiveWorkbook
Set s = b.Sheets("Sheet1")
Set r = s.Range("A1:C10")
r.Value = Application.Transpose(x)
endTime = Timer
MsgBox endTime - startTime
End Sub