Sub CALC2_()
Application.ScreenUpdating = False
Dim rng As Range
With ThisWorkbook.Sheets("INV")
Set rng = Intersect(.Range("L2:L1000"), .Range("L:L,P:P,T:T,X:X,AB:AB,AF:AF,AJ:AJ,AN:AN,AR:AR,AV:AV,AZ:AZ,BD:BD,BH:BH,BL:BL,BP:BP,BT:BT,BX:BX,CB:CB,CF:CF,CJ:CJ,CN:CN,CR:CR,CV:CV,CZ:CZ,DD:DD,DH:DH,DL:DL,DP:DP,DT:DT,DX:DX,EB:EB,EF:EF,EJ:EJ,EN:EN,ER:ER,EV:EV,EZ:EZ,FD:FD,FH:FH,FL:FL,FP:FP,FT:FT"))
For Each cell In rng
' IF INVENTAIRE IS EMPTY AND COMMANDE IS EMPTY
If IsEmpty(cell.Value) And IsEmpty(cell.Offset(0, 2).Value) Then
'THEN
'EPUISE = ""
cell.Offset(0, 1).Value = ""
'TOTAL = ""
cell.Offset(0, 3).Value = ""
' IF INVENTAIRE IS NUMERIC AND COMMANDE IS NUMERIC AND LAST TOTAL IS NUMERIC
ElseIf IsNumeric(cell.Value) And IsNumeric(cell.Offset(0, 2).Value) And IsNumeric(cell.Offset(0, -1).Value) Then
'THEN
'EPUISE = LAST TOTAL - INVENTAIRE
cell.Offset(0, 1).Value = cell.Offset(0, -1).Value - cell.Value
'TOTAL = INVENTAIRE + COMMANDE
cell.Offset(0, 3).Value = cell.Value + cell.Offset(0, 2).Value
' IF INVENTAIRE IS NUMERIC AND COMMANDE IS NUMERIC AND LAST TOTAL IS NUMERIC
ElseIf IsNumeric(cell.Value) And IsNumeric(cell.Offset(0, 2).Value) And (cell.Offset(0, -1).Value = "NOUVEAU" Or cell.Offset(0, -1).Value = "nouveau") Then
'THEN
'EPUISE = LAST TOTAL - INVENTAIRE
cell.Offset(0, 1).Value = "NOUVEAU"
'TOTAL = INVENTAIRE + COMMANDE
cell.Offset(0, 3).Value = cell.Value + cell.Offset(0, 2).Value
' IF INVENTAIRE IS NUMERIC AND COMMANDE IS NUMERIC AND LAST TOTAL IS NOT NUMERIC
ElseIf IsNumeric(cell.Value) And IsNumeric(cell.Offset(0, 2).Value) And Not IsNumeric(cell.Offset(0, -1).Value) Then
'THEN
'EPUISE = "TEXT dans TOTAL"
cell.Offset(0, 1).Value = "TEXT dans TOTAL"
'TOTAL = INVENTAIRE + COMMANDE
cell.Offset(0, 3).Value = cell.Value + cell.Offset(0, 2).Value
' IF INVENTAIRE IS NOT NUMERIC AND COMMANDE IS NUMERIC
ElseIf Not IsNumeric(cell.Value) And IsNumeric(cell.Offset(0, 2).Value) Then
'THEN
'EPUISE = "TEXTE dans INV"
cell.Offset(0, 1).Value = "TEXTE dans INV"
'TOTAL =
cell.Offset(0, 3).Value = cell.Offset(0, 2).Value
ElseIf IsNumeric(cell.Value) And Not IsNumeric(cell.Offset(0, 2).Value) And IsNumeric(cell.Offset(0, -1).Value) Then
'THEN
'EPUISE = LAST TOTAL - INVENTAIRE
cell.Offset(0, 1).Value = cell.Offset(0, -1).Value - cell.Value
'TOTAL = "TEXTE dans COMMANDE"
cell.Offset(0, 3).Value = "TEXTE dans COMMANDE"
ElseIf Not IsNumeric(cell.Value) Or Not IsNumeric(cell.Offset(0, 2).Value) Then
'THEN
'EPUISE = "TEXT"
cell.Offset(0, 1).Value = "TEXT"
'TOTAL = "TEXT"
cell.Offset(0, 3).Value = "TEXT"
Exit Sub
End If
Next
End With
Application.ScreenUpdating = True
End Sub