Boostez vos compétences Excel avec notre communauté !
Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !
Function Renverse(Target As Range) As String[INDENT]Renverse = StrReverse(Target)[/INDENT]
End Function
=DROITE(C6;TROUVE(CAR(32);Renverse(C6))-1)& " (" &GAUCHE(C6;TROUVE(DROITE(C6;TROUVE(CAR(32);Renverse(C6))-1);C6)-1)&")"
Il va de soi que le code s'adapte de lui-même aux longueur des listes à traiter. Si vous ajoutez quelques items dans la colonne B de la feuille Calcul, il vous suffit d'exécuter la procédure tata pour mettre à jour les colonnes AI et AJ.(...) ROGER2327, j'ai téléchargé le fichier que vous avez modifié, cela fonctionne très bien mais comment dois-je faire pour que cela fonctionne sur une liste de 4800 noms de rue, voire même sur une liste de rue départementale (environ 80000 noms de rue). (...)
Merci pour vos réponse JCGL, modeste geedee et ROGER2327.
Cela va beaucoup m'aider et surtout me faire gagner énormément de temps.
Par contre, ROGER2327, j'ai téléchargé le fichier que vous avez modifié, cela fonctionne très bien mais comment dois-je faire pour que cela fonctionne sur une liste de 4800 noms de rue, voire même sur une liste de rue départementale (environ 80000 noms de rue).
With Range("B5")
a = Range(.Cells, Cells(Rows.Count, .Column).End(xlUp)).Value
End With
Ensuite, comment dois-je faire si je veux rajouter des types de voie dans l'onglet paramètres pour qu'ils soient pris en compte par le Virtual Basic (exemple : passage, passerelle, écluse, etc.....)
=DROITE(B6;NBCAR(B6)-SIERREUR(SIERREUR(SIERREUR(TROUVE(" DE ";B6;1)+3;TROUVE(" DU ";B6;1)+3);TROUVE(" D'";B6;1)+2);TROUVE(" ";B6;1)))&" "&"("&GAUCHE(B6;NBCAR(B6)-NBCAR(DROITE(B6;NBCAR(B6)-SIERREUR(SIERREUR(SIERREUR(TROUVE(" DE ";B6;1)+3;TROUVE(" DU ";B6;1)+3);TROUVE(" D'";B6;1)+2);TROUVE(" ";B6;1)))))&")"
Function Glossaire(c As String) As String
Dim oRegExp As Object, matches As Object
Set oRegExp = CreateObject("vbscript.regexp")
With oRegExp
.Global = True
.Pattern = ".*((?:AVENUE|BOULEVARD|COURS|PLACE|PROMENADE|RUE|ROUTE|CARREFOUR|CHEMIN|ESPLANADE|IMPASSE|QUAI|RUELLE|ROND-POINT|VOIE|Z.A.C.|Z.I.)\s+(?:AUX |D'|DE (?:LA |L')?|DES )?)(.*)"
If .test(c) = True Then Glossaire = .Replace(c, "$2 ($1)")
End With
Set oRegExp = Nothing: Set matches = Nothing
End Function
(A1 étant la cellule comportant la chaîne à traiter).=Glossaire(A1)
Sub tata()
Dim i&, j&, tmp$, a(), b()
P1: With Feuil2.Range("A1")
b = .Parent.Range(.Offset(0, 2).Cells, .Parent.Cells(.Parent.Rows.Count, .Offset(0, 2).Column).End(xlUp).Offset(1)).Value
End With
b(UBound(b), 1) = " "
P2: With Feuil1.Range("B5")
a = .Parent.Range(.Cells, .Parent.Cells(.Parent.Rows.Count, .Column).End(xlUp)).Value
End With
ReDim Preserve a(1 To UBound(a), 1 To 2)
For i = 2 To UBound(a)
tmp = UCase(WorksheetFunction.Trim(a(i, 1)))
For j = 1 To UBound(b)
If InStr(1, tmp, UCase(b(j, 1))) Then
a(i, 2) = Right$(tmp, Len(tmp) - Len(b(j, 1))) & " (" & UCase(Trim(b(j, 1))) & ")"
Exit For
End If
Next
Next
P3: With Feuil1.Range("AI5")
.Resize(UBound(a), 2).Value = a
End With
End Sub
Sub toto()
Dim i&, j&, k&, tmp$, a(), b()
P1: With Feuil2.Range("A1")
a = .Parent.Range(.Cells, .Parent.Cells(.Parent.Rows.Count, .Column).End(xlUp)).Value
With .Offset(0, 1)
b = .Parent.Range(.Cells, .Parent.Cells(.Parent.Rows.Count, .Column).End(xlUp).Offset(1)).Value
End With
b(UBound(b), 1) = " "
With Application: .ScreenUpdating = 0: .EnableEvents = 0: .Calculation = -4135: End With
With .Offset(0, 2)
.Parent.Columns(.Column).Resize(.Parent.Rows.Count - .Row + 1, 1).Offset(.Row - 1).ClearContents
For i = 1 To UBound(a)
tmp = a(i, 1)
For j = 1 To UBound(b)
.Offset(k).Value = tmp & b(j, 1)
k = k + 1
Next
Next
End With
With Application: .Calculation = -4105: .EnableEvents = 1: .ScreenUpdating = 1: End With
End With
End Sub
P3: With Feuil1.Range("AI5")
P3: With Sheets("Résultat").Range("D8")
Sub tutu()
Dim i&, j&, tmp$, a(), b()
P1: b = paramètres(Feuil2.Range("A1"))
P2: With Feuil1.Range("B5")
a = .Parent.Range(.Cells, .Parent.Cells(.Parent.Rows.Count, .Column).End(xlUp)).Value
End With
ReDim Preserve a(1 To UBound(a), 1 To 2)
For i = 2 To UBound(a)
tmp = UCase(WorksheetFunction.Trim(a(i, 1)))
For j = 1 To UBound(b)
If InStr(1, tmp, UCase(b(j))) Then
a(i, 2) = Right$(tmp, Len(tmp) - Len(b(j))) & " (" & UCase(Trim(b(j))) & ")"
Exit For
End If
Next
Next
P3: With Feuil1.Range("AI5")
.Resize(UBound(a), 2).Value = a
End With
End Sub
Private Function paramètres(RData As Range)
Dim i&, j&, k&, tmp$, a(), b(), c()
With RData
a = .Parent.Range(.Cells, .Parent.Cells(.Parent.Rows.Count, .Column).End(xlUp)).Value
With .Offset(0, 1)
b = .Parent.Range(.Cells, .Parent.Cells(.Parent.Rows.Count, .Column).End(xlUp).Offset(1)).Value
End With
b(UBound(b), 1) = " "
ReDim c(1 To UBound(a) * UBound(b))
With .Offset(0, 2)
For i = 1 To UBound(a)
tmp = a(i, 1)
For j = 1 To UBound(b)
k = k + 1
c(k) = tmp & b(j, 1)
Next
Next
End With
End With
paramètres = c
End Function
Function Glossaire(c As String) As String
Dim oRegExp As New RegExp
c = Trim(c)
With oRegExp
.Global = True
.IgnoreCase = True
.Pattern = "\s{2,}"
If .Test(c) = True Then c = .Replace(c, " ")
.Pattern = ".*((?:AVENUE|BOULEVARD|COURS|PASSAGE|PLACE|PROMENADE|RUE|ROUTE|CARREFOUR|CHEMIN|ESPLANADE|IMPASSE|QUAI|RUELLE|ROND-POINT|VOIE|Z.A.C.|Z.I.)\s+(?:AU |AUX |À (?:L')?|D'|DU |DE (?:LA |L')?|DES )?)(.*)"
If .Test(c) = True Then Glossaire = Replace(.Replace(c, "$2 ($1)"), " )", ")")
End With
Set oRegExp = Nothing
End Function
Je vous lis avec intérêt Roger (si vous désirez des informations sur les expressions régulières, je suis à votre disposition bien entendu) !J'ai intégré la nouvelle version de la fonction de david84 (que je salue), mais, ne maîtrisant pas les expressions régulières, je ne sais pas y intégrer les nouveaux paramètres (autoroute, pont, ...) : david84, si vous lisez ces lignes...
Function Glossaire(c As String) As String 'Version 3
Dim oRegExp As New RegExp
c = Trim(c)
With oRegExp
.Global = True
.IgnoreCase = True
.Pattern = "\s{2,}"
If .Test(c) = True Then c = .Replace(c, " ")
.Pattern = ".*\b((?:AVENUE|BOULEVARD|COURS|PASSAGE|PLACE|PROMENADE|RUE|(?:AUTO)?ROUTE|CARREFOUR|CHEMIN|ESPLANADE|IMPASSE|PONT|QUAI|RUELLE|ROND(?:-|\s)POINT|VOIE|Z.A.C.|Z.I.)\s+(?:AU |AUX |À (?:L')?|D'|DU |DE (?:LA |L')?|DES )?)(.*)"
If .Test(c) = True Then Glossaire = Replace(.Replace(c, "$2 ($1)"), " )", ")")
End With
Set oRegExp = Nothing
End Function
Oui au fait, où est nemounet11 ?À nemounet11 : que pensez-vous de ces différentes méthodes ? Avez-vous trouvé votre bonheur ?
Bonjour,
Je vous lis avec intérêt Roger (si vous désirez des informations sur les expressions régulières, je suis à votre disposition bien entendu) !
A+
We use cookies and similar technologies for the following purposes:
Est ce que vous acceptez les cookies et ces technologies?
We use cookies and similar technologies for the following purposes:
Est ce que vous acceptez les cookies et ces technologies?