PDA

View Full Version : [SOLVED:] Comparison isn't finding as true; but values sent to MsgBox show it should be....



mongoose
07-19-2019, 11:17 AM
Here is a portion of my code..



'Loop through each SOP audit file
For Each oFile In oFiles
'MsgBox (RemoveLeadingZeroes(Split(oFile.Name, "-")(2)))
'Loop through all SOP IDs stored in COL A
For Each cel In SOPID
MsgBox (RemoveLeadingZeroes(Split(oFile.Name, "-")(2)) & " : " & cel)
'See if SOP ID in COL A matches SOP ID in Audit file name
If RemoveLeadingZeroes(Split(oFile.Name, "-")(2)) = cel Then
MsgBox ("Match found on SOP ID: " & cel)
End If
Next cel
Next oFile


Here is a screenshot of the values being compared using the line...


MsgBox (RemoveLeadingZeroes(Split(oFile.Name, "-")(2)) & " : " & cel)

24646

Why isn't the If() statement triggering the MsgBox saying there is a match if both values do in fact match? Is it treating one as a string and the other value as a range? Could that affect it?

mongoose
07-19-2019, 11:40 AM
Got it...needed to use Trim() to remove some whitespace!