Abstract

If you want distribute a given number of parliament seats to parties in a fair relation with regards to the votes they got, you can use the (external link!) d’Hondt method.

sbdHondt_01_Screen

Appendix sbDHondt Code

Please read my Disclaimer.

Option Explicit

Function sbdHondt(lSeats As Long, vVotes As Variant) As Variant
'Implements the d'Hondt method for allocating seats in
'party-list proportional representation political election
'systems.
'Source (EN): http://www.sulprobil.de/sbdhondt_en/
'Source (DE): http://www.berndplumhoff.de/sbdhondt_de/
'(C) (P) by Bernd Plumhoff 01-Dec-2009 PB V0.10
Dim i As Long, k As Long, n As Long
Dim vA As Variant, vB As Variant, vR As Variant
Dim dMax As Double

With Application.WorksheetFunction
vA = .Transpose(.Transpose(vVotes))
vB = vA
n = UBound(vA, 1)
ReDim vR(1 To n, 1 To 1) As Variant
ReDim lDenom(1 To n) As Long

Do While i < lSeats
    'identify max
    dMax = .Max(vB)
    k = .Match(dMax, vB, 0)
    lDenom(k) = lDenom(k) + 1
    vB(k, 1) = vA(k, 1) / (lDenom(k) + 1#)
    vR(k, 1) = vR(k, 1) + 1
    i = i + 1
Loop
sbdHondt = vR
End With
End Function

Download

Please read my Disclaimer.

sbDHondt.xlsm [24 KB Excel file, open and use at your own risk]