G
Gary Keramidas
i can't seem to remember, can a collection only hold 256 elements?
Here's a macro that has no problem adding 64K items to a collection
although
it takes a minute or so to run. Perhaps your dataset had 256 unique
values
and no more, so it was capping there. I commented out the key
assignment in
the test macro, but it would work uncommented too since all the values
generated below are unique.
Sub CollectionTester()
Dim coll As Collection, n As Long
Dim cell As Range
' Create a list of values all the way down col A
For Each cell In Range("A1:A65536")
cell.Value = cell.Address(0, 0)
Next
' Add to the collection every value in the list
Set coll = New Collection
For Each cell In Range("A1:A65536")
coll.Add cell.Value ', cell.Value ' Optional
Next
' Loop through the collection and
' put the values in column 2
For n = 1 To coll.Count
Cells(n, 2).Value = coll(n)
Next
Set coll = Nothing
End Sub
--
Regards,
Tim Zych
'Compare Excel data with Workbook Compare Pro. Flexible Excel compare
tool.' (http://www.higherdata.com)
Workbook Compare - Excel data comparison utility
Simon:
I re-read my reply to you and it sounds kind of blunt. To clarify, I
agree
with End(xlup) etc for when code should be migrated to production. Your
change creates a different operating result. Whereas my example
populates
65536 rows, yours changes data in the userdrange. It's actually quite
different than my macro.
Regards,
Tim
--
Regards,
Tim Zych
'Compare Excel data with Workbook Compare Pro. Flexible Excel compare
tool.' (http://www.higherdata.com)
Workbook Compare - Excel data comparison utility
tool.' (http://www.higherdata.com)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.