randomly allocating client relationship managers to different clients

nmusoke17

New Member
Joined
Jun 5, 2024
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
I have a list of over 1000 clients I want to allocate to 6 client relationship managers (CRMs) randomly in an equitable way. These clients have varying amounts to pay and these CRMs have to follow-ups with them such that the money is paid on time. How do I randomly allocate these CRMs to the different clients equitably such that all of them view it as a fair distribution in terms of the number of clients and amounts to be followed up each is allocated
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
paste this code into a module

make a sheet called : Managers (see image)
make a sheet called : Clients
the Tier column is used to put clients into a blocks with money range, so each manager gets high and low value clients
or set all tiers to the same value

run macro: genThePicks
and it will divide the clients.

Code:
Public Sub genThePicks()
Dim colMgrs As New Collection, colClients As New Collection, colTiers As New Collection, colClientTier As New Collection
Dim m As Integer, c As Integer, iRnd As Integer, r As Integer, t As Integer, i As Integer
Dim vMgr, vVal, vCli, vCliTier
Dim iCliPerMgr As Integer
Dim sTier As String, sKey As String
Dim bFound As Boolean

On Error GoTo errGen

'===== collect managers
Sheets("managers").Select
Range("A2").Select
While ActiveCell.Value <> ""
    vMgr = ActiveCell.Value
    colMgrs.Add vMgr, vMgr

    ActiveCell.Offset(1, 0).Select ' next row
Wend

'===== collect clients & tiers
Sheets("Clients").Select
Range("A2").Select
While ActiveCell.Value <> ""
    vCli = ActiveCell.Value
    sTier = ActiveCell.Offset(0, 1).Value
    
    sKey = vCli & "," & sTier
    colClientTier.Add sKey, sKey
    
    'colClients.Add vCli, vCli
    colTiers.Add sTier, sTier

    ActiveCell.Offset(1, 0).Select ' next row
Wend

iCliPerMgr = colClients.Count \ colMgrs.Count

'==== make result manager sheets
For m = 1 To colMgrs.Count
    Sheets.Add
    ActiveSheet.Name = colMgrs(m)
Next

'------split up clients to mgrs using money tiers
For t = 1 To colTiers.Count
    sTier = colTiers(t)
    
      'fill the client collection with only clients w that 1 tier to pick from
    Set colClients = New Collection
    For c = 1 To colClientTier.Count
         vCliTier = colClientTier(c)
         
         If InStr(vCliTier, sTier) > 0 Then
            sKey = Left(vCliTier, InStr(vCliTier, ",") - 1)
            colClients.Add sKey, sKey
         End If
        
    Next
    
    For m = 1 To colMgrs.Count
        vMgr = colMgrs(m)
        Sheets(vMgr).Select
        
         GoSub getRndClient
              
              'assign client
            vCli = colClients(r)
            ActiveCell.Value = vCli
            ActiveCell.Offset(1, 0).Select ' next row
            
            colClients.Remove vCli
   Next m
Next t


endit:
Set colMgrs = Nothing
Set colTiers = Nothing
Set colClients = Nothing
Set colClientTier = Nothing

MsgBox "done"

Exit Sub

getRndClient:
    r = getRndNum(colClients.Count)
    vCliTier = colClientTier(r)
Return

errGen:
Select Case Err
  Case 457
    Resume Next
  Case Else
    MsgBox Err.Description, , Err
End Select
End Sub


Private Function getRndNum(ByVal piLimit As Integer)
getRndNum = Int(piLimit * Rnd + 1)
End Function
 

Attachments

  • sheet names.jpg
    sheet names.jpg
    62.8 KB · Views: 4
Upvote 0

Forum statistics

Threads
1,226,074
Messages
6,188,727
Members
453,494
Latest member
Alt F11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top