Classement 1er 2eme ... Avec formule rang

Aloish

XLDnaute Nouveau
Bonjour,

Pourriez-vous m'apporter un peu d'aide svp ?
J’essaye d'intégrer dans ma formule RANG des nombres ordinaux
Très clairement je voudrais arriver à ce résultat : "1er sur 21 villes" ou "15ème sur 21 villes"
j'ai essayé d'y intégrer une fonction SI mais en vain ...
Help,
Merci,
 

Pièces jointes

  • RANG.xlsx
    12.2 KB · Affichages: 135
  • RANG.xlsx
    12.2 KB · Affichages: 107
  • RANG.xlsx
    12.2 KB · Affichages: 110

Regueiro

XLDnaute Impliqué
Re : Classement 1er 2eme ... Avec formule rang

Bonjour Le Forum, Aloish

Formule à tester

Code:
=SI(RANG(B11;B3:B26;0)=1;RANG(B11;B3:B26;0)&"er sur "&NB.SI(B3:B26;">0")&" villes";RANG(B11;B3:B26;0)&"ème sur "&NB.SI(B3:B26;">0")&" villes")

A+
 

job75

XLDnaute Barbatruc
Bonsoir Patrick et les autres,
On peut pas !
On peut avec un p'tit coup de VBA :
VB:
Private Sub Worksheet_Calculate()
Dim P As Range, c As Range, ex As Range
Set P = Columns("D").SpecialCells(xlCellTypeFormulas)
P.NumberFormat = "[=1]0"" er"";0"" ème"""
For Each c In P
    If Application.CountIf(P, c) > 1 Then Set ex = Union(IIf(ex Is Nothing, c, ex), c)
Next
If Not ex Is Nothing Then ex.NumberFormat = "[=1]0"" er ex"";0"" ème ex"""
End Sub
A+
 

Pièces jointes

  • Rang(1).xlsm
    21 KB · Affichages: 22

job75

XLDnaute Barbatruc
S'il y a beaucoup de lignes Application.Countif (NB.SI) prend trop de temps, on utilisera le Dictionary :
VB:
Private Sub Worksheet_Calculate()
Dim P As Range, d As Object, tablo, i&, ex As Range
Set P = Columns("D").SpecialCells(xlCellTypeFormulas)
Set d = CreateObject("Scripting.Dictionary")
tablo = P 'matrice, plus rapide
For i = 1 To UBound(tablo)
    d(tablo(i, 1)) = d(tablo(i, 1)) + 1
Next
P.NumberFormat = "[=1]0"" er"";0"" ème"""
For i = 1 To UBound(tablo)
    If d(tablo(i, 1)) > 1 Then Set ex = Union(IIf(ex Is Nothing, P(i), ex), P(i))
Next
If Not ex Is Nothing Then ex.NumberFormat = "[=1]0"" er ex"";0"" ème ex"""
End Sub
Fichier (2) avec seulement 2000 lignes.
 

Pièces jointes

  • Rang(2).xlsm
    77 KB · Affichages: 18

Discussions similaires