Bonjour Forum, salut Bonzai, salut vba_new
J'ai enfin le résultat attendu, c'est bluffant, je vous dit à tous un grand merci ! De la part des collègues aussi, qui vont également profiter de ce travail.
Je colle à la suite le code, adapté à mon "vrai" fichier :
Option Explicit
Sub perfect_steering()
Dim I As Integer
Dim J As Long
Dim K As Byte
Dim F As Byte
Dim Lg As Long
Dim Msg As String
Dim Titre
Dim ColDep
Dim ColFin
Dim Cel As Range
Application.ScreenUpdating = False
Titre = Array("Type 1", "Type 2", "Type 3", "Type 4")
ReDim ColDep(UBound(Titre))
ReDim ColFin(UBound(Titre))
Lg = Range("A" & Rows.Count).End(xlUp).Row + 1
If Lg > 6 Then
Range("A6:E" & Lg).ClearContents
End If
Lg = 6
For F = 13 To 16
With Sheets(F)
For I = 0 To UBound(Titre)
Set Cel = .Rows(11).Find(what:=Titre(I), LookIn:=xlValues, lookat:=xlWhole)
If Not Cel Is Nothing Then
ColDep(I) = Cel.Column
J = Cel.Column
While .Cells(11, J).MergeCells = True And .Cells(11, J + 1) = ""
J = J + 1
Wend
ColFin(I) = J
Else
MsgBox "Incorrect data format in the sheet " & .Name
Exit Sub
End If
Next I
For J = 14 To .Range("C" & .Rows.Count).End(xlUp).Row
If .Range("G" & J) <> "" Then
For K = 0 To UBound(ColDep)
Msg = ""
For I = ColDep(K) To ColFin(K)
If .Cells(J, I) <> "" And UCase(.Cells(J, I)) <> "OK" And UCase(.Cells(J, I)) <> "KO" Then
Msg = Msg & .Cells(J, I) & ","
End If
Next I
If Len(Msg) > 0 Then
Cells(Lg, "A") = .Range("C" & J)
Cells(Lg, 2 + K) = Left(Msg, Len(Msg) - 1)
End If
Next K
Lg = Lg + 1
End If
Next J
End With
Next F
Columns("A:E").AutoFit
End Sub
Encore merci à tous ! Et Banzai !! ^^ (cf Groland)
Très cordialement,
** Pierrot **