+ Reply to Thread
Results 1 to 4 of 4

Random Selection Macro by Location and Ranking (High/Med/Low)

Hybrid View

  1. #1
    Registered User
    Join Date
    08-18-2013
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Random Selection Macro by Location and Ranking (High/Med/Low)

    Hi all,

    I am looking to create a macro to provide a random testing list of people based on their location and ranking. For example, wanting a list of a sample list of 3 individuals located in Sydney with a ranking from High, Med to Low.

    I have attached a sample of the data set as a guide.

    Any advise would be appreciated?


    Regards

    J
    Attached Files Attached Files

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Random Selection Macro by Location and Ranking (High/Med/Low)

    We would need the workbook password.

  3. #3
    Registered User
    Join Date
    08-18-2013
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Random Selection Macro by Location and Ranking (High/Med/Low)

    Sorry,

    Password: Bud2014

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Random Selection Macro by Location and Ranking (High/Med/Low)

    This is similar to what I've done in other thread, but not really sure how you want the result.

    Try and if this is not how you wanted, Need to see your expected result in your workbook.

    Sub test()
        Dim a, i As Long, e, s, n As Long
        Const myCity As String = "Sydney"
        a = Cells(1).CurrentRegion.Value
        Randomize
        With CreateObject("Scripting.Dictionary")
            .CompareMode = 1
            For i = 2 To UBound(a, 1)
                If Not .exists(a(i, 4)) Then
                    Set .Item(a(i, 4)) = _
                    CreateObject("Scripting.Dictionary")
                    .Item(a(i, 4)).CompareMode = 1
                End If
                If Not .Item(a(i, 4)).exists(a(i, 8)) Then
                    Set .Item(a(i, 4))(a(i, 8)) = _
                    CreateObject("System.Collections.SortedList")
                End If
                .Item(a(i, 4))(a(i, 8))(Rnd) = a(i, 2)
            Next
            For Each e In .keys
                For Each s In .Item(e).keys
                    n = n + 1
                    a(n, 1) = e
                    a(n, 2) = s
                    a(n, 3) = .Item(e)(s).GetByIndex(0)
                Next
            Next
            Cells(2, "k").Resize(n, 3).Value = a
        End With
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 02-06-2012, 05:46 PM
  2. ranking formula used in conjunction with a selection box
    By waternut in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2012, 09:57 PM
  3. Selection and ranking 10 highest values
    By roberto1111 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-29-2010, 08:02 PM
  4. Random Number Generation for Cell Location
    By pfunkallstar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-10-2009, 12:53 PM
  5. Multiple Sheets and random location of Info.
    By harryg in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 02-02-2005, 05:17 PM

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