Salut Daniel,
Salut Eric,
il a fallu le temps que je "contrôle" ces sal... de cellules fusionnées...
Fonction personnalisée fctHoraire()
Public Function fctHoraire() As String
'
Dim rCel1 As Range, iRow%, iCol%, iNbCol%, iIdx%
'
Application.Volatile
iRow = Application.Caller.Row
'
With Worksheets(Application.Caller.Parent.Name)
For x = 2 To 43
If .Cells(iRow, x) <> "" And IsNumeric(.Cells(iRow, x)) Then
Set rCel = .Cells(iRow, x)
iNbCol = rCel.MergeArea.Cells.Count
If x = 2 Then
sHoraire = "8H30"
Else
iIdx = 0
If rCel.Offset(0, -1).Interior.Color = RGB(255, 255, 255) Then iIdx = 1
If rCel.Offset(0, 1).Interior.Color = RGB(255, 255, 255) Then iIdx = 2
If iIdx > 0 Then
iCol = rCel.Cells(1, IIf(iIdx = 1, 1, iNbCol)).Column
sHoraire = sHoraire & IIf(iIdx = 1, IIf(sHoraire = "", "", " / "), "-")
If iIdx = 1 Then sHoraire = sHoraire & Split(.Cells(4, iCol - IIf(iCol Mod 4 = 3, 0, (iCol Mod 4) + 1)), "H")(0)
If iIdx = 2 Then sHoraire = sHoraire & Split(.Cells(4, iCol - IIf(iCol Mod 4 = 2, -1, (iCol Mod 4) + 1)), "H")(0)
sHoraire = sHoraire & IIf(iIdx = 1, _
Choose((iCol Mod 4) + 1, "H15", "H30", "H45", "H00"), _
Choose((iCol Mod 4) + 1, "H30", "H45", "H00", "H15"))
End If
End If
End If
Next
End With
fctHoraire = sHoraire
'
End Function
A+