Hi iuliandonici,
Try:
Code:
Sub InOut()
Application.ScreenUpdating = False
Dim StrIn As String, StrOut As String, i As Long
Dim StrSub As String, StrAdd As String, j As Long
With ActiveSheet()
For i = 7 To .Range("C" & .Rows.Count).End(xlUp).Row
StrAdd = ""
StrSub = ""
StrIn = Trim(Replace(.Cells(i, 3).Value, ";", ""))
StrOut = Trim(Replace(.Cells(i, 4).Value, ";", ""))
If UBound(Split(StrIn, " ")) = UBound(Split(StrOut, " ")) Then
For j = 0 To UBound(Split(StrIn, " "))
StrAdd = StrAdd & CLng(Split(StrIn, " ")(j)) + CLng(Split(StrOut, " ")(j)) & " "
StrSub = StrSub & CLng(Split(StrIn, " ")(j)) - CLng(Split(StrOut, " ")(j)) & " "
Next
StrAdd = Replace(StrAdd, " ", "; ")
StrSub = Replace(StrSub, " ", "; ")
Else
StrAdd = "IN/OUT item counts differ"
StrSub = "IN/OUT item counts differ"
End If
.Cells(i, 5).Value = StrAdd
.Cells(i, 6).Value = StrSub
Next
End With
Application.ScreenUpdating = True
End Sub