Sub catchDiscrepancies() Dim myWS As Worksheet Dim sourceBCounter As Long Dim sourceACounter As Long Dim amount As String Dim bQuantity As Double
Dim matFound As Boolean
Set myWS = ThisWorkbook.Sheets("SAP")
sourceBCounter = 2 Do While myWS.Range("G" & sourceBCounter).Value <> "" matFound = False
sourceACounter = 2 Do While myWS.Range("A" & sourceACounter).Value <> "" If myWS.Range("A" & sourceACounter).Value = myWS.Range("G" & sourceBCounter).Value And myWS.Range("C" & sourceACounter).Value = myWS.Range("J" & sourceBCounter).Value Then matFound = True Exit Do End If sourceACounter = sourceACounter + 1 Loop If matFound Then If InStr(1, UCase(myWS.Range("B" & sourceACounter).Value), "KG", vbTextCompare) = 0 Then myWS.Range("L" & sourceBCounter).Value = "Bad: Could not find KG in description" Else If InStr(1, UCase(myWS.Range("B" & sourceACounter).Value), " KG", vbTextCompare) = 0 Then amount = Left(myWS.Range("B" & sourceACounter).Value, InStr(1, UCase(myWS.Range("B" & sourceACounter).Value), "KG", vbTextCompare) - 1) Else amount = Left(myWS.Range("B" & sourceACounter).Value, InStr(1, UCase(myWS.Range("B" & sourceACounter).Value), " KG", vbTextCompare) - 1) End If If InStr(1, amount, " ", vbTextCompare) > 0 Then amount = Mid(amount, InStrRev(amount, " ") + 1) End If End If bQuantity = CDbl(amount) * myWS.Range("K" & sourceBCounter).Value If bQuantity <> myWS.Range("D" & sourceACounter).Value Then myWS.Range("L" & sourceBCounter).Value = "Bad: A Qty: " & myWS.Range("D" & sourceACounter).Value & " <> B Qty: " & bQuantity Else myWS.Range("L" & sourceBCounter).Value = "Ok" End If Else myWS.Range("L" & sourceBCounter).Value = "Bad: Not found in source A list" End If sourceBCounter = sourceBCounter + 1
Loop
End Sub
It definitely loaded and went through but I don't see any changes at all