re,
Voici un petit code qui va te faire ce que tu demandes
1. Suis ces indications :
- ALT + F11 sur ton clavier pour aller en VBA
- Menu Insertion / Module qui va te donner une fenêtre blanche à droite
- Colle le code ci-dessous
Const lig As Byte = 3
Sub MFC()
' Macro Dan pour oSMoZ le 06/08/09
'http://www.excel-pratique.com/forum/viewtopic.php?t=12687
Dim a As Byte, b As Byte, col As Byte
Dim imin, imax
Application.ScreenUpdating = False
ActiveSheet.PivotTables("rendement equipe").PivotSelect ("Resp"), xlDataOnly
With Selection.Font
.ColorIndex = 0
.Bold = False
End With
b = Selection.Columns.Count
On Error Resume Next
For a = 1 To Selection.Rows.Count
With Application.WorksheetFunction
imin = .Min(Range(Cells(a + lig, 5), Cells(a + lig, b + 4)))
If imin <> 0 Then
col = .Match(imin, Range(Cells(a + lig, 5), Cells(a + lig, b + 4)), 0)
With Cells(a + lig, col + 4).Font
.ColorIndex = 3
.Bold = True
End With
End If
End With
With Application.WorksheetFunction
imax = .Max(Range(Cells(a + lig, 5), Cells(a + lig, b + 4)))
If imax <> 0 Then
col = .Match(imax, Range(Cells(a + lig, 5), Cells(a + lig, b + 4)), 0)
With Cells(a + lig, col + 4).Font
.ColorIndex = 10
.Bold = True
End With
End If
End With
Next
Range("A1").Select
End Sub
- Enregistre ton fichier
2. Ensuite :
- Clique droite sur l'onglet où se trouve le TCD
- Choisis "Visualiser le code"
- Colle le code ci-après
Private Sub Worksheet_Activate()
Call MFC
End Sub
- Enregistre ton fichier
Pour faire un essai, clique sur un onglet autre que celui du TCD, puis clique à nouveau sur l'onglet contenant le TCD.
Tes macros doivent activées dans excel. Pour le faire, vas dans Outils / Macro / sécurité des macros puis mets sur "niveau moyen".
Amicalement
Dan