donc v tec ... a besoin de l'ordre ... décroissant
merci James, je m'étais accroché sur le croissant
v tec, voici la correction,
Sub test()
Set sh = Sheets("100")
fichier = ThisWorkbook.Path & "\allergènes" & sh.Name & ".txt"
'Kill fichier
With sh
derCol = .Cells(20, Columns.Count).End(xlToLeft).Column
qte = Application.CountIf(.Range(.Cells(20, 5), .Cells(20, derCol)), ">0")
For i = 1 To qte
pvl = Application.Large(.Range(.Cells(20, 5), .Cells(20, derCol)), i)
If pvl > .Range("B2") Then
colpvl = Application.Match(pvl, .Range(.Cells(20, 5), .Cells(20, derCol)), 0) + 4
liste = liste & ";" & .Cells(4, colpvl)
End If
Next
End With
ChDir ThisWorkbook.Path
nomfichier = "allergènes" & sh.Name
Open nomfichier & ".txt" For Append As #1
Print #1, liste
Close #1
End Sub