Sub MiseEnForme()
Dim LstRow&, i&, j&, K&
Dim TabSource As Variant, TabReport As Variant, Tmp As Variant
Dim Discrit$
Discrit = "CNMR"
With ActiveSheet
LstRow = .Cells(.Rows.Count, 1).End(xlUp).Row
TabSource = .Range(.Cells(1, 1), .Cells(LstRow, 21))
K = Application.CountIf(.Columns("c"), "Total") + 1
End With
ReDim TabReport(1 To K, 1 To 21)
K = 1
TabReport(1, 1) = TabSource(1, 1)
For i = 3 To UBound(TabSource, 2)
TabReport(1, i - 1) = TabSource(1, i)
Next i
For i = LBound(TabSource, 1) + 1 To UBound(TabSource, 1)
If TabSource(i, 3) = "Total" Then
K = K + 1
Tmp = Split(TabSource(i, 1), "_")
Select Case Tmp(LBound(Tmp))
Case Discrit
TabReport(K, 1) = Tmp(LBound(Tmp))
Case Else
TabReport(K, 1) = Tmp(UBound(Tmp))
End Select
For j = 3 To UBound(TabSource, 2)
Select Case j
Case 4, 15, 21
TabReport(K, j - 1) = Format(TabSource(i, j), "[H]hh:mm")
Case 7, 8, 19, 20
Tmp = Split(TabSource(i, j), ":")
TabReport(K, j - 1) = Tmp(1) & ":" & Tmp(2)
Case Else
TabReport(K, j - 1) = TabSource(i, j)
End Select
Next j
End If
Next i
With Sheets.Add(after:=Sheets(Sheets.Count))
.Name = "MiseEnForme_" & Sheets.Count - 1
.Cells(1, 1).Resize(UBound(TabReport, 1), UBound(TabReport, 2)).Value = TabReport
.Columns.AutoFit
End With
End Sub