Function InversePrenomNom(chaine) Application.Volatile i = Len(chaine) Do While Asc(Mid(chaine, i, 1)) < 96 And i > 1 i = i - 1 Loop InversePrenomNom = Mid(chaine, i + 2) & " " & Left(chaine, i) End Function
3-Noms composés en majuscules avec Accent:
Function InversePrenomNom2(chaine) Application.Volatile chaine2 = sansAccent(chaine) If Asc(Right(chaine2, 1)) < 96 Then p = InStr(chaine2, " ") If p > 0 Then InversePrenomNom2 = Mid(chaine, p + 1) & " " & Left(chaine, p - 1) ' 1 lettre pour le prénom Else InversePrenomNom2 = chaine ' pas de prénom End If Else i = 1 Do While Asc(Mid(chaine2, i, 1)) < 96 And i < Len(chaine) i = i + 1 Loop InversePrenomNom2 = Mid(chaine, i - 1) & " " & Left(chaine, i - 3) End If End Function
Function sansAccent(chaine) codeA = "ÉÈÔéèêë" codeB = "EEOeeee" temp = chaine For i = 1 To Len(temp) p = InStr(codeA, Mid(temp, i, 1)) If p > 0 Then Mid(temp, i, 1) = Mid(codeB, p, 1) Next sansAccent = temp End Function
http://cjoint.com/?chk2r8lOyY
Cordialement JB
On 7 fév, 10:15, Pijay <P...@discussions.microsoft.com> wrote:
Bonjour,
J'ai un fichier excel avec 200 contacts.
Ils sont sous la forme "prenom nom" et je les voudrais en "nom prenom"...
Merci
Bonjour,
1-Cas simple: prenom nom séparés par un espace (pas de noms composes
avec espaces)
Function InversePrenomNom(chaine)
Application.Volatile
i = Len(chaine)
Do While Asc(Mid(chaine, i, 1)) < 96 And i > 1
i = i - 1
Loop
InversePrenomNom = Mid(chaine, i + 2) & " " & Left(chaine, i)
End Function
3-Noms composés en majuscules avec Accent:
Function InversePrenomNom2(chaine)
Application.Volatile
chaine2 = sansAccent(chaine)
If Asc(Right(chaine2, 1)) < 96 Then
p = InStr(chaine2, " ")
If p > 0 Then
InversePrenomNom2 = Mid(chaine, p + 1) & " " & Left(chaine, p -
1) ' 1 lettre pour le prénom
Else
InversePrenomNom2 =
chaine ' pas de prénom
End If
Else
i = 1
Do While Asc(Mid(chaine2, i, 1)) < 96 And i < Len(chaine)
i = i + 1
Loop
InversePrenomNom2 = Mid(chaine, i - 1) & " " & Left(chaine, i - 3)
End If
End Function
Function sansAccent(chaine)
codeA = "ÉÈÔéèêë"
codeB = "EEOeeee"
temp = chaine
For i = 1 To Len(temp)
p = InStr(codeA, Mid(temp, i, 1))
If p > 0 Then Mid(temp, i, 1) = Mid(codeB, p, 1)
Next
sansAccent = temp
End Function
Function InversePrenomNom(chaine) Application.Volatile i = Len(chaine) Do While Asc(Mid(chaine, i, 1)) < 96 And i > 1 i = i - 1 Loop InversePrenomNom = Mid(chaine, i + 2) & " " & Left(chaine, i) End Function
3-Noms composés en majuscules avec Accent:
Function InversePrenomNom2(chaine) Application.Volatile chaine2 = sansAccent(chaine) If Asc(Right(chaine2, 1)) < 96 Then p = InStr(chaine2, " ") If p > 0 Then InversePrenomNom2 = Mid(chaine, p + 1) & " " & Left(chaine, p - 1) ' 1 lettre pour le prénom Else InversePrenomNom2 = chaine ' pas de prénom End If Else i = 1 Do While Asc(Mid(chaine2, i, 1)) < 96 And i < Len(chaine) i = i + 1 Loop InversePrenomNom2 = Mid(chaine, i - 1) & " " & Left(chaine, i - 3) End If End Function
Function sansAccent(chaine) codeA = "ÉÈÔéèêë" codeB = "EEOeeee" temp = chaine For i = 1 To Len(temp) p = InStr(codeA, Mid(temp, i, 1)) If p > 0 Then Mid(temp, i, 1) = Mid(codeB, p, 1) Next sansAccent = temp End Function
http://cjoint.com/?chk2r8lOyY
Cordialement JB
Pijay
Merci c'est top !
On 7 fév, 10:15, Pijay wrote:
Bonjour, J'ai un fichier excel avec 200 contacts.
Ils sont sous la forme "prenom nom" et je les voudrais en "nom prenom"...
Merci
Bonjour,
1-Cas simple: prenom nom séparés par un espace (pas de noms composes avec espaces)
Function InversePrenomNom(chaine) Application.Volatile i = Len(chaine) Do While Asc(Mid(chaine, i, 1)) < 96 And i > 1 i = i - 1 Loop InversePrenomNom = Mid(chaine, i + 2) & " " & Left(chaine, i) End Function
3-Noms composés en majuscules avec Accent:
Function InversePrenomNom2(chaine) Application.Volatile chaine2 = sansAccent(chaine) If Asc(Right(chaine2, 1)) < 96 Then p = InStr(chaine2, " ") If p > 0 Then InversePrenomNom2 = Mid(chaine, p + 1) & " " & Left(chaine, p - 1) ' 1 lettre pour le prénom Else InversePrenomNom2 > chaine ' pas de prénom End If Else i = 1 Do While Asc(Mid(chaine2, i, 1)) < 96 And i < Len(chaine) i = i + 1 Loop InversePrenomNom2 = Mid(chaine, i - 1) & " " & Left(chaine, i - 3) End If End Function
Function sansAccent(chaine) codeA = "ÉÈÔéèêë" codeB = "EEOeeee" temp = chaine For i = 1 To Len(temp) p = InStr(codeA, Mid(temp, i, 1)) If p > 0 Then Mid(temp, i, 1) = Mid(codeB, p, 1) Next sansAccent = temp End Function
http://cjoint.com/?chk2r8lOyY
Cordialement JB
Merci c'est top !
On 7 fév, 10:15, Pijay <P...@discussions.microsoft.com> wrote:
Bonjour,
J'ai un fichier excel avec 200 contacts.
Ils sont sous la forme "prenom nom" et je les voudrais en "nom prenom"...
Merci
Bonjour,
1-Cas simple: prenom nom séparés par un espace (pas de noms composes
avec espaces)
Function InversePrenomNom(chaine)
Application.Volatile
i = Len(chaine)
Do While Asc(Mid(chaine, i, 1)) < 96 And i > 1
i = i - 1
Loop
InversePrenomNom = Mid(chaine, i + 2) & " " & Left(chaine, i)
End Function
3-Noms composés en majuscules avec Accent:
Function InversePrenomNom2(chaine)
Application.Volatile
chaine2 = sansAccent(chaine)
If Asc(Right(chaine2, 1)) < 96 Then
p = InStr(chaine2, " ")
If p > 0 Then
InversePrenomNom2 = Mid(chaine, p + 1) & " " & Left(chaine, p -
1) ' 1 lettre pour le prénom
Else
InversePrenomNom2 > chaine ' pas de prénom
End If
Else
i = 1
Do While Asc(Mid(chaine2, i, 1)) < 96 And i < Len(chaine)
i = i + 1
Loop
InversePrenomNom2 = Mid(chaine, i - 1) & " " & Left(chaine, i - 3)
End If
End Function
Function sansAccent(chaine)
codeA = "ÉÈÔéèêë"
codeB = "EEOeeee"
temp = chaine
For i = 1 To Len(temp)
p = InStr(codeA, Mid(temp, i, 1))
If p > 0 Then Mid(temp, i, 1) = Mid(codeB, p, 1)
Next
sansAccent = temp
End Function
Function InversePrenomNom(chaine) Application.Volatile i = Len(chaine) Do While Asc(Mid(chaine, i, 1)) < 96 And i > 1 i = i - 1 Loop InversePrenomNom = Mid(chaine, i + 2) & " " & Left(chaine, i) End Function
3-Noms composés en majuscules avec Accent:
Function InversePrenomNom2(chaine) Application.Volatile chaine2 = sansAccent(chaine) If Asc(Right(chaine2, 1)) < 96 Then p = InStr(chaine2, " ") If p > 0 Then InversePrenomNom2 = Mid(chaine, p + 1) & " " & Left(chaine, p - 1) ' 1 lettre pour le prénom Else InversePrenomNom2 > chaine ' pas de prénom End If Else i = 1 Do While Asc(Mid(chaine2, i, 1)) < 96 And i < Len(chaine) i = i + 1 Loop InversePrenomNom2 = Mid(chaine, i - 1) & " " & Left(chaine, i - 3) End If End Function
Function sansAccent(chaine) codeA = "ÉÈÔéèêë" codeB = "EEOeeee" temp = chaine For i = 1 To Len(temp) p = InStr(codeA, Mid(temp, i, 1)) If p > 0 Then Mid(temp, i, 1) = Mid(codeB, p, 1) Next sansAccent = temp End Function