Compare 2 lists to capture discrepencies
VBA Telemetry pings you when your VBA projects fail
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Compare 2 lists to capture discrepencies

  1. #1
    Board Regular
    Join Date
    Mar 2009
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Compare 2 lists to capture discrepencies

     

    I have two lists of emails to compare with each other.
    The first list is on excel, and the second list is on word.

    The list of emails on excel is on a column as shown below.
    JOHNSMITH@HOTMAIL.COM
    MATHEWPETER@HOTMAIL.COM
    MARKJACOB@HOTMAIL.COM
    PAULDOUMIT@HOTMAIL.COM
    And the second list which is copied pasted from outlook onword is as shown below. All are on the same line.
    smith, john ; mathew, peter; sharma,monica ;mark, jacob

    I want to compare both lists to capture discrepancies.

  2. #2
    Board Regular
    Join Date
    Mar 2013
    Posts
    768
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Compare 2 lists to capture discrepencies

    what version of excel do you have?

  3. #3
    Board Regular
    Join Date
    Mar 2009
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Compare 2 lists to capture discrepencies

    Excel 2010

  4. #4
    Board Regular
    Join Date
    Mar 2013
    Posts
    768
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Compare 2 lists to capture discrepencies


  5. #5
    Board Regular
    Join Date
    Mar 2009
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Compare 2 lists to capture discrepencies

    Thank you....i ll try that.

    Correction to my earlier thread:

    I have two lists of emails to compare with each other.
    The first list is on excel, and the second list is on word.


    The list of emails on excel is on a column as shown below.
    JOHNSMITH@HOTMAIL.COM
    MATHEWPETER@HOTMAIL.COM
    MARKJACOB@HOTMAIL.COM
    PAULDOUMIT@HOTMAIL.COM

    And the second list which is copied pasted from outlook onword is as shown below.
    smith, john < johnsmith@hotmail.com >; mathew, peter < mathewpeter@hotmail.com > ; sharma,monica < monicasharma@hotmail.com > ; mark,jacob <markjacob@hotmail.com >


    I want to compare both lists to capture discrepancies.

  6. #6
    Board Regular
    Join Date
    Mar 2013
    Posts
    768
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Compare 2 lists to capture discrepencies

    to me this looks like you need VBA for this one, I'm Not sure how to do it, I hope that the link that I sent helps

  7. #7
    Board Regular
    Join Date
    Nov 2012
    Posts
    178
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Compare 2 lists to capture discrepencies

    jamtay317 is correct, you'll need some VBA to achieve this. Whereabouts in Outlook is the list copied from (a mail item, an address list etc)? I ask because rather than using a reference to the Word Object Library and comparing the strings, it might be more useful to go directly to Outlook.

  8. #8
    Board Regular
    Join Date
    Mar 2009
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Compare 2 lists to capture discrepencies

    how do i do that? I am familiar a bit with VBA. I do have access to outlook for the complete list of emails.
    I just thought it would be easier to copy/paste it in word.
    Last edited by maramiro; Apr 29th, 2013 at 01:56 PM.

  9. #9
    Board Regular
    Join Date
    Nov 2012
    Posts
    178
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Compare 2 lists to capture discrepencies

    You could alter this code to deal with the matches/discrepancies however you wish

    Code:
    Sub GetAddressesWord()
    
    Dim wdApp As Object 'Word.Application
    Dim strWord As String
    Dim rng As Range, c As Range
    
    
    Set wdApp = GetObject(, "Word.Application")
    strWord = LCase(wdApp.ActiveDocument.Range)
    Set rng = Sheets(1).Range("A1:A4")
    
    
        For Each c In rng
            If InStr(1, strWord, LCase(c)) > 1 Then
                Debug.Print c & " - Matches"
            Else
                Debug.Print c & " - Discrepancy"
            End If
        Next
        
    Set rng = Nothing
    Set wdApp = Nothing
    
    
    End Sub
    There's no need to add a reference to the Word Object Library (but you can and then replace Object with the comment). You will need to have the Word document open for this to work, and you'll need to change "rng" to the relevant range in your spreadsheet.

    Hope this helps

    Simon

  10. #10
    Board Regular
    Join Date
    Apr 2013
    Posts
    128
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Compare 2 lists to capture discrepencies

      
    Quote Originally Posted by maramiro View Post
    Thank you....i ll try that.

    Correction to my earlier thread:

    I have two lists of emails to compare with each other.
    The first list is on excel, and the second list is on word.


    The list of emails on excel is on a column as shown below.
    JOHNSMITH@HOTMAIL.COM
    MATHEWPETER@HOTMAIL.COM
    MARKJACOB@HOTMAIL.COM
    PAULDOUMIT@HOTMAIL.COM

    And the second list which is copied pasted from outlook onword is as shown below.
    smith, john < johnsmith@hotmail.com >; mathew, peter < mathewpeter@hotmail.com > ; sharma,monica < monicasharma@hotmail.com > ; mark,jacob <markjacob@hotmail.com >


    I want to compare both lists to capture discrepancies.
    Hi,

    I don't think you need VBA to achieve this if your total length of emails from outlook does not exceed 32767 characters (Excel limit)

    1. below is the way to convert the outlook emails list to excel cells

    copy the whole email list, go to excel, go to cell A1, in the formula bar, Paste the emails

    A B C
    3 Find "<" position Find ">" position E-mail address
    4 =FIND("<", $A$1) =FIND(">", $A$1) =TRIM(MID($A$1, $A4+1, $B4-$A4-1))
    5 =FIND("<", $A$1, A4+1) =FIND(">", $A$1, B4+1) =TRIM(MID($A$1, $A5+1, $B5-$A5-1))
    6 =FIND("<", $A$1, A5+1) =FIND(">", $A$1, B5+1) =TRIM(MID($A$1, $A6+1, $B6-$A6-1))

    note: formulas of A4 & B4 are different to other cells in that column
    for other formulas, you can just drag down

    2. I think it would be easy to compare this list to your excel list (either by A to B VLOOKUP & B to A VLOOKUP, or if you like you may use MATCH function to lookup), by both way round then you can see what are the discrepancies between the 2 lists completely
    (Excel is not case sensitive for VLOOKUP/MATCH)

    Alvin

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com