Create an array inside a For...Next loop
Sub test()
Dim r As Long
Dim arr(1 To 100, 1 To 1) As String
For r = 1 To 100
If Cells(r, 1) = "X" Then
arr(r, 1) = "found"
End If
Next
Workbooks.Open Filename:="C:\Test.xls"
Sheets("Sheet2").Select
Range(Cells(2), Cells(100, 2)) = arr
End Sub
RBS
"Eric Winegarner" wrote in
message ...
I will be looping through a dynamic range of cells, and when my condition
is
met I want to add that value to an array, and then empty the contents of
the
array onto a different spreadsheet. As a simple example:
'Adding item to array
For each cel in Range("A1:A100")
If cell.value = "X" Then
add cell value to my array
end
Next cell
'Writing data to new spreadsheet
For each cell in Range("B1:B100")
add array item to current cell
Next cell
Does anyone have any suggestions? Thanks in a advance!
|