Re : macro évenementielle tourne en boucle
euh 🙂
j'ai certe pas mal de chose à faire dans la macro "Mise_en_forme" qui peuvent être amélioré niveau languistique VB 🙂
mais ca passe sans probléme 😀 (je met le code de la mise à jour si ca peut interesser..
sinon concernant le code fourni pour ,j'en a fait ca mais ca marche pas :x
Enfin ca marche uniquement quand je clique dans les cellule concernée et pas lorsque je change les champs du TCD 🙁 via les listes déroulantes du TCD
en A6.B12.
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
If Not Application.Intersect(Target, Range("A6:B12")) Is Nothing Then
Application.EnableEvents = False
Call Tranche_TCD
Application.EnableEvents = True
End If
End Sub
----------------------------------------------------------------------------------
Sub Mise_en_forme()
On Error Resume Next
Application.ScreenUpdating = False
'''''''''''''''''''''''''''''''''''''''''Mise à jour du TCD
ActiveSheet.PivotTables("TDC_tranche").PivotCache.Refresh
ActiveSheet.PivotTables("TDC_tranche").PivotSelect "",
'''''''''''''''''''''''''''''''''''''''Format du TCD
xlDataAndLabel, True
ActiveSheet.PivotTables("TDC_tranche").Format xlReport6
''''''''''''''''''''''''''''''''''''''''format des colonnes
Columns("C:CM").ColumnWidth = 5
Dim col, I As Variant
For I = 13 To 60
If Cells(7, I) = 0 Then Columns(I).Hidden = True
Next I
'''''''''''''''''''''''''''''''''''''''format des champ du TDC (saleté de texte qui se met en écriture vertical à chaque rafraichissement du TCD)
Range("A6").Copy
Range("A6:B12").Select
Range("B6").Activate
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
''''''''''''''''''''''''''''''''orientation des cellules du TCD
ActiveSheet.PivotTables("TDC_Tranche").PivotSelect "", xlDataAndLabel, True
With Selection
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
''''''''''''''''''''format de ligne de champ du TDC à mettre verticales
Range("INTITULE").Select 'intitule = ligne 13:13
With Selection
.Orientation = 90
End With
Range("A7:B11").Select
With Selection
.HorizontalAlignment = xlLeft
End With
''''''''''''''''''''''''''''''''''''''réécritures des entéte de colonne du TDC
Rows("6:6").UNMERGE
Dim R1, P1, I1, M1, C1 As Variant
R1 = Range("IV1")
P1 = Range("IV2")
I1 = Range("IV3")
M1 = Range("IV4")
C1 = Range("IV5")
Cells(6, R1).Select
Cells(6, R1)= "RECEPTION"
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
.Value = "RECEPTION"
'End With
'Range(Cells(6, R1), Cells(6, R1 + 10)).Merge
Cells(6, P1) = "PARAGE"
Cells(6, P1).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Range(Cells(6, P1), Cells(6, P1 + 11)).Merge
Cells(6, I1) = "INJECTION"
Cells(6, I1).Select
With Selection.Interior
.ColorIndex = 41
.Pattern = xlSolid
End With
Range(Cells(6, I1), Cells(6, I1 + 11)).Merge
Cells(6, M1).Select
With Selection.Interior
.ColorIndex = 45
.Pattern = xlSolid
.Value = "MOULAGE"
End With
Range(Cells(6, M1), Cells(6, M1 + 11)).Merge
Cells(6, C1).Select
Cells(6, C1) = "MOULAGE"
With Selection.Interior
.ColorIndex = 4
.Pattern = xlSolid
End With
Range(Cells(6, C1), Cells(6, C1 + 11)).Merge
End Sub