Private Sub CommandButton1_Click()
Dim netC As Workbook
Dim pep As Worksheet
Dim nom_fichier As String
Dim repertoire As String
Dim comtpeur As String
Dim compteur2 As Integer
Dim stock As String
Dim i As Integer

Application.ScreenUpdating = False
Application.Visible = False
Application.Calculation = xlCalculationManual


'Définition du fichier de travail avec un parcourir qui s'ouvre tout seul
nom_fichier = Application.GetOpenFilename
repertoire = Left(nom_fichier, InStrRev(nom_fichier, "\"))  'sert à obtenir le répertoire
nom_fichier = Mid(nom_fichier, InStrRev(nom_fichier, "\") + 1, 100) ' sert à obtenir le nom.extension

'Définition du classeur de travail
Set netC = Workbooks(nom_fichier)
Set pep = netC.Worksheets("Feuil1")


'Suppression des colonnes inutiles dans l'ordre
pep.Columns("B:B").Delete Shift:=xlToLeft
pep.Columns("F:Z").Delete Shift:=xlToLeft


'Refusionner les cellules pour faire une jolie mise en page
pep.Range("A5:E5").Merge
pep.Range("A5:E5").HorizontalAlignment = xlCenter
pep.Range("A7:E7").Merge
pep.Range("A7:E7").HorizontalAlignment = xlCenter


'Tout aligner au centre de la cellule
pep.Range("A:E" + CStr(compteur)).HorizontalAlignment = xlCenter
pep.Range("A:E" + CStr(compteur)).VerticalAlignment = xlCenter


'Aligner verticalement au centre de la cellule les colonnes
For i = 9 To compteur
    pep.Range(Split(pep.Cells(i, 1).MergeArea.Address, ":")(0)).VerticalAlignment = xlCenter
    pep.Range(Split(pep.Cells(i, 2).MergeArea.Address, ":")(0)).VerticalAlignment = xlCenter
    pep.Range(Split(pep.Cells(i, 3).MergeArea.Address, ":")(0)).VerticalAlignment = xlCenter
    pep.Range(Split(pep.Cells(i, 4).MergeArea.Address, ":")(0)).VerticalAlignment = xlCenter
    pep.Range(Split(pep.Cells(i, 5).MergeArea.Address, ":")(0)).VerticalAlignment = xlCenter
Next i


'Déplacer la ligne 5 vers la ligne 6 et mettre au centre de la ligne 6
pep.Range("A6:E6").Value = pep.Range("A5:J5").Value
pep.Range("A6:E6").HorizontalAlignment = xlCenter


'Supprimer les lignes 1 à 5 + 148-149
pep.Rows("1:5").Delete
pep.Rows("148:149").Delete


'Mettre une bordure horizontale sur toutes les colonnes jusqu'en haut
For i = 1 To 148
For j = 1 To 5
        With pep.Cells(i, j).Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
    Next j
Next i


'Mettre une bordure verticale sur toutes les colonnes jusqu'en haut
For i = 1 To 147
    For j = 1 To 5
        With pep.Cells(i, j).Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
    Next j
Next i


'Mettre une bordure large verticale sur toutes les colonnes jusqu'en haut
For i = 1 To 147
    For j = 1 To 6
        With pep.Cells(i, j).Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThick
        End With
    Next j
Next i


'Mettre une bordure large horizontale
'Toutes les 3 lignes sauf pour les lignes 1, 2 et 3
For i = 1 To 4
For j = 1 To 5
        With pep.Cells(i, j).Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThick
        End With
    Next j
Next i

For i = 4 To compteur Step 3
    For j = 1 To 5
         With pep.Cells(i, j).Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThick
        End With
    Next j
Next i


'Ajout de la colonne Tube
pep.Columns("E:E").Insert Shift:=xlToRight
pep.Range("E3").Value = "Tube"


'mettre en forme la colone cable
For i = 4 To 148
    For j = 6 To 6
    With pep.Cells(i, j)
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .WrapText = True
            .Orientation = 90
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = True
            .Font.Bold = True
            .Font.Size = 15
        End With
    Next j
Next i





'CREDITS
Application.Calculation = xlCalculationAutomatic
Application.Visible = True
Application.ScreenUpdating = True





End Sub





Public Function choisir_couleur_modulo(modulo As Integer)

    If modulo = 1 Then
        choisir_couleur_modulo = 255
    End If
    
    If modulo = 2 Then
        choisir_couleur_modulo = 16711680
    End If
    
    If modulo = 3 Then
        choisir_couleur_modulo = 32768
    End If
    
    If modulo = 4 Then
        choisir_couleur_modulo = 65535
    End If
    
    If modulo = 5 Then
        choisir_couleur_modulo = 8388736
    End If
    
    If modulo = 7 Then
        choisir_couleur_modulo = 39423
    End If
    
    If modulo = 10 Then
        choisir_couleur_modulo = 65280
    End If
    
    If modulo = 11 Then
        choisir_couleur_modulo = 16776960
    End If
    
    If modulo = 12 Then
        choisir_couleur_modulo = 13408767
    End If
    
    If modulo = 8 Then
        choisir_couleur_modulo = 8421504
    End If
    
    If modulo = 9 Then
        choisir_couleur_modulo = 13209
    End If
    
    If modulo = 6 Then
        choisir_couleur_modulo = 16777215
    End If

End Function






Public Sub afficher()

Application.Calculation = xlCalculationAutomatic
Application.Visible = True
Application.ScreenUpdating = True

End Sub




