Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Transformation d'un format tableau en un autre

mumuriton

XLDnaute Occasionnel
Bonjour,

Voici mon soucis, un peu compliqué je dois l'admettre.

Dans le fichier, il y a deux onglets qui ont les mêmes données mais dans un format différent.
Comment puis je faire pour que les données du tableau de l'onglet 1 se transforme en tableau de l'onglet 2?

Pas simple.
Merci à tous
Murielle
 

Pièces jointes

  • SYNTHESE.xlsx
    40.9 KB · Affichages: 40
  • SYNTHESE.xlsx
    40.9 KB · Affichages: 42

klin89

XLDnaute Accro
Re : Transformation d'un format tableau en un autre

Bonsoir CISCO, mumuriton, le forum

Au préalable, créer une feuille nommée "Feuil1"
Sous réserve, de garder la même structure des données.
A tester :
VB:
Option Explicit

Sub test()
Dim r As Range, rng As Range, derlig As Long
Dim i As Long, j As Byte, n As Long
    Application.ScreenUpdating = False
    Sheets("Feuil1").Cells.Clear
    With Sheets("LIVRAISON TRANSPORT")
        n = 1: derlig = .Cells(Rows.Count, 1).End(xlUp).Row
        For i = 4 To derlig
            Set rng = .Range(.Cells(i, 1), .Cells(i, 31))
            With rng.Offset(, 1).Resize(, rng.Columns.Count - 1)
                On Error Resume Next
                Set r = .RowDifferences(.Find("", lookat:=xlWhole))
                On Error GoTo 0
            End With
            If Not r Is Nothing Then
                With Sheets("Feuil1")
                    For j = 1 To r.Areas.Count
                        n = n + 1
                        .Cells(n, 1) = rng.Cells(1).Value
                        .Cells(n, 2) = r.Areas(j)(3 - i, 1)
                        r.Areas(j).Copy
                        .Cells(n, 3).PasteSpecial xlPasteValues
                    Next
                End With
            End If
            Set r = Nothing
        Next
        With Sheets("Feuil1").Cells(1)
            .Resize(1, 8).Value = Array("Usine", "Jour", "S", _
                                        "Propriétaire", "Chantier", "T", "Prod", "V. (st)")
            With .CurrentRegion
                .Font.Name = "calibri"
                .Font.Size = 10
                .VerticalAlignment = xlCenter
                .BorderAround Weight:=xlThin
                .Borders(xlInsideVertical).Weight = xlThin
                With .Rows(1)
                    .BorderAround Weight:=xlThin
                    .Interior.ColorIndex = 38
                End With
                .Columns.AutoFit
            End With
            .Parent.Activate
        End With
    End With
    Set rng = Nothing
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
klin89
 

Discussions similaires

Réponses
13
Affichages
225
Réponses
1
Affichages
232
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…