These are the two formulas from the OP's #1, but there have been several corrections to them

Does anyone have the current error-less versions?

    With Range("AY59:EX" & lLR) 
        .Formula = "=IF(OR($AF59="""",$AF59="""",$AJ59=""""),0,IF(AY$58<$AJ59,0,IF(AY$58>=$AJ59,IF(0<($AN59),MIN(($AN59-SUM(AX59:$AX59)),$AO59,SUMIF(Shadow_Dept_Lines_Sum_Col,$AM59,AY$4:AY$56)-SUMIF($AM$58:$AM58,$AM59,AY$58))))))" 
        .Value = .Value 
    End With 
     
    With Range("AW59:AW" & lLR) 
        .Formula = "=AN59-SUM(AY59:EX59)" 
        .Value = .Value 
    End With