LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Function to create a collection

Hi,

I'm trying to create a collection from a given range of cells. The
code seems to run but the collection I try to create (in this case
called "MainCategory") has no data in it. Can anybody help?

Thanks,
Derek


Public MainCategory As New Collection
Dim AllCells As Range

Sub Test()
<code
Set AllCells = Range(Range("top_label").Offset(1, 0),
Rang("top_label").End(xlDown))

' Create a new collection
Set MainCategory = CreateCollection(AllCells)
End Sub

Function CreateCollection(AllCells As Range) As Collection
Dim Cell
'Prevents errors from trying to have duplicate entries
On Error Resume Next
For Each Cell In AllCells
CreateCollection.Add Cell.Value, CStr(Cell.Value)
Next Cell
On Error GoTo 0
End Function
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
template for dvd collection David Excel Discussion (Misc queries) 2 April 26th 10 11:35 PM
data collection driller Excel Discussion (Misc queries) 1 October 13th 09 01:04 AM
how do i create a data collection form in excel? stacy New Users to Excel 1 October 26th 05 08:21 PM
Does anybody have a CD collection template PeterM Excel Discussion (Misc queries) 2 November 27th 04 05:46 PM
sheet collection Tom Ogilvy Excel Programming 0 October 28th 03 03:15 PM


All times are GMT +1. The time now is 07:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"