Consulting

Results 1 to 2 of 2

Thread: Comparison isn't finding as true; but values sent to MsgBox show it should be....

  1. #1
    VBAX Regular
    Joined
    Jul 2019
    Posts
    51
    Location

    Lightbulb Comparison isn't finding as true; but values sent to MsgBox show it should be....

    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)
    ss5.JPG

    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?

  2. #2
    VBAX Regular
    Joined
    Jul 2019
    Posts
    51
    Location
    Got it...needed to use Trim() to remove some whitespace!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •