H o l a:
Te anexo la macro para que funcione con 2, con 3 o con los números de días hábiles que quieras.
Solamente cambia en esta línea n = 3 el número de días hábiles.
Sub nPagos()
'Por.Dante Amor
n = 3 'número de días hábiles
Range("E3:E" & Range("E" & Rows.Count).End(xlUp).Row + 3).ClearContents
For i = Range("D" & Rows.Count).End(xlUp).Row To 3 Step -1
If Cells(i, "B") = "No habil" Then
Cells(i, "E") = "No habil"
Else
sumar = 0: llevouno = 0
For j = i - 1 To 2 Step -1
If j < 3 Then
Cells(i, "E") = "No hay datos"
Exit For
End If
If Cells(j, "B") = "Habil" Then
If llevouno = n - 1 Then
Cells(i, "E") = sumar + Cells(j, "D")
Exit For
Else
llevouno = llevouno + 1
End If
Else
If llevouno = n - 1 Then sumar = sumar + Cells(j, "D")
End If
Next
End If
Next
MsgBox "Fin"
End Sub
' : )
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias
' : )