Bonsoir Philippe et le forum.
Suite à ton aide, j’ai essayé ta phrase et je n’y suis pas arrivé. J’ai complètement changé d’idée et suis parti sur ' SpecialCells(xlCellTypeVisible ' et ça donne ceci qui marche bien.
Il y a sûrement plus simple et plus beau. Si quelqu'un veut me corriger, je suis preneur.
Merci encore pour ton aide.
Francis
Sub tri()
valtest = 'bureau'
lignetotal = 0
lignerouge = 0
Derligne = Cells(rows.Count, 'f').End(xlUp).Row
Range(Cells(11, 2), Cells(Derligne, 2)).EntireRow.Hidden = True
Application.ScreenUpdating = False
'trie les articles
For l = Derligne To 11 Step -1
MotCherche = Application.Find(valtest, Cells(l, 4))
If Not (IsError(MotCherche)) Then
lignetotal = lignetotal + 1
Cells(l, 4).EntireRow.Hidden = False
End If
Next
'compte et cache les lignes rouges
Set MaPlage = Range(Cells(11, 2), Cells(Derligne, 2))
Set MaPlage = MaPlage.SpecialCells(xlCellTypeVisible)
For Each cell In MaPlage
If cell.Font.ColorIndex = 3 Then
lignerouge = lignerouge + 1
cell.EntireRow.Hidden = True
End If
Next
'reaffiche les lignes rouges
For Each cell In MaPlage
If cell.Font.ColorIndex <> 1 Then
cell.EntireRow.Hidden = False
End If
Next
[e6] = lignetotal & ' articles au total'
[e7] = lignerouge & ' articles rouges'
[e8] = lignetotal - lignerouge & ' articles noirs'
End Sub