XL 2013 Suppression espaces inutiles

Appo1985

XLDnaute Occasionnel
Bonsoir à tous.
J'ai voulu supprimer par vba les espaces de trop dans mon tableau mais ce sont les seulement les espaces en début de cellule qui sont supprimés.
Je voudrais de l'aide .
Merci d'avance
Ci-joint mon fichier
 

Pièces jointes

  • majuscule et nom propre.xlsm
    17.9 KB · Affichages: 5
Solution
Hello

Un essai avec ce code
VB:
Sub Bouton1_Cliquer()
Dim c As Range
    For Each c In Range("Tableau1")
        tempo = Split(c, " ")
        d = ""
        For i = 0 To UBound(tempo)
            If tempo(i) <> "" Then
                d = d & tempo(i) & " "
            End If
            
        Next i
        c = UCase(Trim(d))
    Next c
    For Each x In Range("Tableau1[Prénom(s)]")
        x.Value = Application.Proper(x.Value)
    Next
End Sub

vgendron

XLDnaute Barbatruc
Hello

Un essai avec ce code
VB:
Sub Bouton1_Cliquer()
Dim c As Range
    For Each c In Range("Tableau1")
        tempo = Split(c, " ")
        d = ""
        For i = 0 To UBound(tempo)
            If tempo(i) <> "" Then
                d = d & tempo(i) & " "
            End If
            
        Next i
        c = UCase(Trim(d))
    Next c
    For Each x In Range("Tableau1[Prénom(s)]")
        x.Value = Application.Proper(x.Value)
    Next
End Sub
 

Appo1985

XLDnaute Occasionnel
Hello

Un essai avec ce code
VB:
Sub Bouton1_Cliquer()
Dim c As Range
    For Each c In Range("Tableau1")
        tempo = Split(c, " ")
        d = ""
        For i = 0 To UBound(tempo)
            If tempo(i) <> "" Then
                d = d & tempo(i) & " "
            End If
           
        Next i
        c = UCase(Trim(d))
    Next c
    For Each x In Range("Tableau1[Prénom(s)]")
        x.Value = Application.Proper(x.Value)
    Next
End Sub
Merci beaucoup @vgendron .
J'ai oublier de préciser que le problème c'est quand il y a deux mots dans la cellule.
Je voudrais aussi supprimer les espaces superflus entre les mots car par la suite je compte faire un tri de A à Z
 

Discussions similaires

Réponses
22
Affichages
1 K

Statistiques des forums

Discussions
312 215
Messages
2 086 325
Membres
103 179
dernier inscrit
BERSEB50