Transposer une colonne

  • Initiateur de la discussion Initiateur de la discussion maval
  • Date de début Date de début

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 !

maval

XLDnaute Barbatruc
Bonjour,

Voila j'ai une liste de nom en colonne "A" que je voudrais transposer en colonne "D" avec un texte et N°.

je joint un fichier explicatif.

Je vous remercie d'avance

Max
 

Pièces jointes

Re Max

VB:
Option Explicit

Sub test()
Dim cr1$, cr2$, derlig&, i&, cr3
    With Feuil1
        derlig = .Cells(Rows.Count, 1).End(xlUp).Row
        cr1 = "<path id="""
        cr2 = "title="""

        For i = 5 To derlig
            cr3 = Format("0" & (i - 5) + 2, "dd")
            .Cells(i, 4) = cr1 & cr3 & """ " & cr2 & .Cells(i, 1)
        Next i
    End With
End Sub
 
Dernière édition:
Re Max

Une autre façon plus ou moins identique

VB:
Sub test()
    Dim cr1$, cr2$, derlig&, i&, x&, cr3
    With Feuil1
        derlig = .Cells(Rows.Count, 1).End(xlUp).Row
        cr1 = "<path id="""
        cr2 = "title="""
        x = 0
        For i = 5 To derlig
          x = x + 1
            cr3 = Format("0" & x + 1, "dd")
            .Cells(i, 4) = cr1 & cr3 & """ " & cr2 & .Cells(i, 1)
        Next i
    End With
End Sub
 
Re Max

Voilà j'ai apporté la modification.

VB:
Sub test()
Dim cr1$, cr2$, derlig&, i&, x&, cr3
    With Feuil1
        derlig = .Cells(Rows.Count, 1).End(xlUp).Row
        cr1 = "<path id="""
        cr2 = "title="""
        x = 0
        For i = 5 To derlig
            x = x + 1
            cr3 = Format("0" & x + 1, "dd")
            .Cells(i, 4) = cr1 & cr3 & """ " & cr2 & .Cells(i, 1)
            If x > 30 Then
                cr3 = x
                .Cells(i, 4) = cr1 & cr3 & """ " & cr2 & .Cells(i, 1)
            End If
        Next i
    End With
End Sub
 
Bonsoir Max

Une correction du code, désolé pour le désagrément. 😳

VB:
Sub test()
Dim cr1$, cr2$, derlig&, i&, x&, cr3

    With Feuil1
        derlig = .Cells(Rows.Count, 1).End(xlUp).Row
        cr1 = "<path id="""
        cr2 = "title="""
        x = 0
        For i = 5 To derlig
            x = x + 1
            cr3 = Format("0" & x, "00")
            .Cells(i, 4) = cr1 & cr3 & """ " & cr2 & .Cells(i, 1)
        Next i
    End With
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

  • Résolu(e)
Microsoft 365 transposer
Réponses
6
Affichages
240
Réponses
7
Affichages
203
  • Question Question
Microsoft 365 agrandir la liste
Réponses
21
Affichages
397
  • Question Question
Microsoft 365 Fonction si
Réponses
7
Affichages
127
  • Résolu(e)
Microsoft 365 problème
Réponses
19
Affichages
776
  • Question Question
Microsoft 365 Aide planning
Réponses
17
Affichages
509
Retour