Re: Simple VBA loop help
try this
Code
Sub RecordLoop()
Dim a, b()
Dim i As Integer, x As Integer
Dim lrow As Long
'write the values of column D to array a
lrow = Sheets("Input").Cells(Rows.Count, "D").End(xlUp).Row
a = Sheets("Input").Range("D1:D" & lrow).Value
'set b to equal size of a
ReDim b(1 To UBound(a, 1), 1 To 1)
'loop through a from end to beginning and write values to b
For i = UBound(a, 1) To LBound(a, 1) Step -1
x = x + 1
b(x, 1) = "Q" & a(i, 1)
Next
'Writes the values of b to Post-processing sheet modify _
the column and/or row number to suit your needs
With Sheets("Post-processing").Cells(1, 1).Resize(UBound(b))
.ClearContents
.Value = b
End With
End Sub
Display More