View Single Post
 
Old 04-13-2011, 01:55 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 04-13-2011 at 01:57 AM. Reason: Minor Code Mods
Reply With Quote