RonMcK
08-09-2008, 06:26 PM
In "AutoFill rows with formula" Malcolm suggested:
Without looping
Sub FiiData()
Range("A1:Y1000").Formula = "=INDIRECT(" & """" & "Sheet2!C" _
& """" & "& (ROW()-1) * 25+COLUMN())"
End Sub
Can I use the following (as part of a sub) to populate some columns on my work sheet with constant data to be taken from Ary2()?
With Sheets(2)
i = 1
NewLastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
While i <= UBound(Ary2)
'// Enter text in cells
Range(Ary2(i, 1) & "2:" & Ary2(i, 1) & _
NewLastRow).Text = Ary2(i, 2)
i = i + 1
Wend
End With
When I tried this, I received a run-time error 1004: Unable to set the Text property of the Range class. Why is that? What is this all about?
I changed this block of code to use the following While loop. This worked through 256 iterations and stopped with an error: run-time error '1004': Application-defined or object-defined error. THE FIX: Color me chagrined. Instead of the 4th column, I was populating the 4th row and got the error when I banged into the right edge of the worksheet. Arrgghhh! Swapped positions of jj and Ary2(i,1). Everything ran perfectly.
With Sheets(2)
ii = 1
NewLastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
While ii <= UBound(Ary2)
jj = 2
While jj <= NewLastRow
'// Enter text in cells
' Debug.Print ii, jj, Ary2(ii, 1), DetColNum(Ary2(ii, 1)), _
Ary2(ii, 2), NewLastRow
.Cells(DetColNum(jj, Ary2(ii, 1))) = Ary2(ii, 2)
jj = jj + 1
Wend
ii = ii + 1
Wend
End With
Any suggestions? There are 350 more lines to process in the column and 3 more columns to process after this first one. And, the, 5 more worksheets to run through my process of which this is a part.
was :banghead: but now it's: :cloud9::thumb
Thanks,
Without looping
Sub FiiData()
Range("A1:Y1000").Formula = "=INDIRECT(" & """" & "Sheet2!C" _
& """" & "& (ROW()-1) * 25+COLUMN())"
End Sub
Can I use the following (as part of a sub) to populate some columns on my work sheet with constant data to be taken from Ary2()?
With Sheets(2)
i = 1
NewLastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
While i <= UBound(Ary2)
'// Enter text in cells
Range(Ary2(i, 1) & "2:" & Ary2(i, 1) & _
NewLastRow).Text = Ary2(i, 2)
i = i + 1
Wend
End With
When I tried this, I received a run-time error 1004: Unable to set the Text property of the Range class. Why is that? What is this all about?
I changed this block of code to use the following While loop. This worked through 256 iterations and stopped with an error: run-time error '1004': Application-defined or object-defined error. THE FIX: Color me chagrined. Instead of the 4th column, I was populating the 4th row and got the error when I banged into the right edge of the worksheet. Arrgghhh! Swapped positions of jj and Ary2(i,1). Everything ran perfectly.
With Sheets(2)
ii = 1
NewLastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
While ii <= UBound(Ary2)
jj = 2
While jj <= NewLastRow
'// Enter text in cells
' Debug.Print ii, jj, Ary2(ii, 1), DetColNum(Ary2(ii, 1)), _
Ary2(ii, 2), NewLastRow
.Cells(DetColNum(jj, Ary2(ii, 1))) = Ary2(ii, 2)
jj = jj + 1
Wend
ii = ii + 1
Wend
End With
Any suggestions? There are 350 more lines to process in the column and 3 more columns to process after this first one. And, the, 5 more worksheets to run through my process of which this is a part.
was :banghead: but now it's: :cloud9::thumb
Thanks,