Private Sub MettreEnForme()
'Application.ScreenUpdating = False
Set wsBCT9 = Sheets("Bon de commande T9")
Set Gabarit = Range("Gabarit")
With wsBCT9
lastLine = .UsedRange.Rows.Count
For i = 1 To lastLine
If .Range("A" & i).MergeCells Then
Gabarit.Copy
.Range("A" & i).Resize(5, 9).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
If .Range("A" & i) = "Visuel Article" Then
Set rngFusion = .Range("B" & i + 4).Resize(, 4)
With rngFusion
.Font.Color = RGB(0, 0, 0) ' Appliquer la couleur noire au texte
.Font.Size = 10
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
.Value = "Eligibilité enseigne: SUP-EXP-CIT-CMK-PS"
End With
End If
i = i + 4
Else 'on est sur une ligne de catégorie
Set rngFusion = .Range("A" & i).Resize(1, 4)
With rngFusion
.Merge
.Font.Bold = True
.Font.Color = RGB(0, 0, 0) ' Appliquer la couleur noire au texte
.Font.Size = 10
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
End With
End If
Next i
'on set tous les sauts de page pour n'avoir que 56 lignes par feuille
ActiveWindow.View = xlPageBreakPreview 'affichage en mode "sauts de page"
lastLine = .UsedRange.Rows.Count
NumSp = 1
i = NumSp
While i < lastLine
Set .HPageBreaks(NumSp).Location = .Range("A" & NumSp * 56 + 1)
NumSp = NumSp + 1
i = NumSp * 56 + 1
Wend
.PageSetup.Zoom = 80
ActiveWindow.View = xlPageLayoutView 'affichage mode "mise en page"
End With
'Application.ScreenUpdating = True
End Sub