Excel(VBA) copier valeurs dans une cellule

Résolu
plastickman Messages postés 66 Statut Membre -  
plastickman Messages postés 66 Statut Membre -
Bonjour à tous,
J'ai dans la colonne A nommée "rubrique" et dans une colonne B des "option" s'y rapportant, ce qui donne :


       A                                B
1     RUBRIQUES               OPTIONS 

2      Machine 1                 option 1 

3                                       option 23    

4                                       option 12 

5      Machine 2                 option 2 

6                                       option 4 

7      Machine 3                  option 1 

8                                       option 112 

9                                       option 8 



Je souhaiterais réaliser un code qui me permettrait d'arriver à ceci:

 
       A                                B    
1     RUBRIQUES                OPTIONS 

2      Machine 1                 option 1 option 23 option 12 

3                                           

4                                        

5      Machine 2                 option 2 option 4 

6                                        

7     Machine 3                  option 1 option 112 option 8 

8                                        

9        


Quelqu'un a -t-il une petite idée à me soumettre?

Merci,

4 réponses

  1. remousse Messages postés 299 Date d'inscription   Statut Membre Dernière intervention   6
     
    L'utilisation de la fonction de concaténation d'excel ne suffirait pas à résoudre le problème par hasard ?
    Par exmeple: =CONCATENER(E13;F13)
    0
  2. ccm81 Messages postés 11033 Statut Membre 2 434
     
    bonjour

    quelque chose comme ça ?

    Option Explicit
    
    Const FO = "Feuil1"
    Const FB = "Feuil2"
    
    Public Sub GrouperOptions()
    Dim derliFO As Long, liFO As Long
    Dim liFB As Long
    Dim rub As String, opt As String
    derliFO = Sheets(FO).Cells(Rows.Count, 2).End(xlUp).Row
    liFB = 2
    liFO = 2
    While liFO < derliFO
      rub = Sheets(FO).Cells(liFO, 1).Value
      opt = Sheets(FO).Cells(liFO, 2).Value
      Sheets(FB).Cells(liFB, 1).Value = rub
      Sheets(FB).Cells(liFB, 2).Value = opt
      liFO = liFO + 1
      While (liFO <= derliFO) And (Sheets(FO).Cells(liFO, 1).Value = "")
        opt = opt & "  " & Sheets(FO).Cells(liFO, 2).Value
        Sheets(FB).Cells(liFB, 2).Value = opt
        liFO = liFO + 1
      Wend
      liFB = liFB + 1
    Wend
    End Sub

    bonne suite
    0
  3. pilas31 Messages postés 1878 Statut Contributeur 648
     
    Bonjour plastickman et ccm81

    J'arrive un peu tard,
    j'ai testé une macro qui fait le tri sur place (dans la même feuille) :

    Sub RANGER()
    DerLig = Columns(2).Find("*", , , , xlByColumns, xlPrevious).Row
    LigMach = 2
    Do
        LigOpt = LigMach + 1
        Do
            If LigOpt > DerLig Then Exit Sub
            Cells(LigMach, 2) = Cells(LigMach, 2) & "," & Cells(LigOpt, 2)
            Rows(LigOpt).Delete Shift:=xlUp
            DerLig = DerLig - 1
        Loop Until Cells(LigOpt, 1) <> ""
        LigMach = LigMach + 1
    Loop
    End Sub


    A+

    --
    Cordialement,
    0
  4. plastickman Messages postés 66 Statut Membre 6
     
    Bonsoir et merci à vous trois,
    Remousse, j'ai bien pensé à CONCATENER, mais j'ai environ 500 lignes à traiter.

    CCM81, ça marche très bien, malgré que je n'ai presque rien compris à ta macro ;)

    Pilas31, ça marche également, sauf dans le cas où une "rubrique " n'a qu'une seule "option" en face dans la colonne B, à ce moment là, la ligne disparait.

    Merci encore,

    jp
    0