+ Reply to Thread
Results 1 to 5 of 5

Need Properties Of New Collection

  1. #1
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    316

    Need Properties Of New Collection

    Sub BuildUniqueItems()
    Dim x as New collection

    On error resume next
    For each c in [a1:g1000]
    x.Add c, CStr(c.value)
    Next
    Counter=x.Count
    Avg=x.Average
    Std=x.Stdev
    Mode =x.Mode 'to cross-test uniqueness

    End sub

    To my bewilderment, the Avg, std, mode return errors. Any help would be appreciated.

    David

  2. #2
    Registered User
    Join Date
    10-25-2004
    Posts
    88
    You should not be bewilderd - a Collection does not have these properties.

    A collection is a bunch of items that are not necessarily numbers: e.g. Worksheets (with ending s) is a Collection. You can count the number of worksheets in the Worksheets collection, but it is hard to average them; Therefore the only property that a standard collection has, is a Count property.

  3. #3
    Registered User
    Join Date
    10-25-2004
    Posts
    88
    As an afterttought, why don't you just use

    =count(a1:g1000)
    =average(a1:g1000)
    =stdev(a1:g1000)
    =mode(a1:g1000)


    For the latter you may need to active the Analysis Toolpack Add-In: Extra -> Add-Ins-> Select analysis Toolpack

  4. #4
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    316

    Need for New Collection Properties

    Rv,

    Thanks for the help. The idea however is not to simply get the summary statistics of the values in the range "a1:g1000" but to draw out the vital stats of the UNIQUE VALUES. If the items processed by the New Collection method are strings with "numeric character", such as in the example, it would be great if the method could allow for some kind data manipulation. I now assume only COUNT works

    DM

  5. #5
    Registered User
    Join Date
    10-25-2004
    Posts
    88
    I see. So you add the items to a collection to weed out the duplicate ones. I'm afraid that in order to calculate let's say, the average, you will have to loop again through that collection and perform the addition and then use the Collection.count to obtain the average.

    Standard deviation should be calculated in a similar way.

    Mode should be undefined! Because the collection is a set of UNIQUE items, all of them occur with the same frequency i.e. 1

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1