+ Reply to Thread
Results 1 to 4 of 4

need vba code to compare two column get result of common values of both column

Hybrid View

breadwinner need vba code to compare two... 11-12-2013, 02:43 AM
AB33 Re: need vba code to compare... 11-12-2013, 03:34 AM
:) Sixthsense :) Re: need vba code to compare... 11-12-2013, 03:59 AM
breadwinner Re: need vba code to compare... 11-12-2013, 05:42 AM
  1. #1
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    need vba code to compare two column get result of common values of both column

    Dear Experts

    I have set of data in Column A and column B i want result as common values of both A and B result in C column.....

    I need vba code please help on this.....
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: need vba code to compare two column get result of common values of both column

    Try this:-
    Attached Files Attached Files

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: need vba code to compare two column get result of common values of both column

    Or

    Sub GetCommonValues()
    Dim oSD As Object, rMyRng As Range, nEndRw1 As Long, nEndRw2 As Long, r As Range
    
    Set oSD = CreateObject("Scripting.Dictionary")
        nEndRw1 = Cells(Rows.Count, "A").End(xlUp).Row
        nEndRw2 = Cells(Rows.Count, "B").End(xlUp).Row
    Set rMyRng = Union(Range("A2:A" & nEndRw1), Range("B2:B" & nEndRw2))
    
    Application.ScreenUpdating = False
    
    With oSD
        .CompareMode = False
        
        For Each r In rMyRng
            If Not .Exists(r.Value) Then .Add r.Value, 1
        Next r
        
        Range("C2").Resize(.Count, 1).Value = Application.Transpose(.Keys)
    End With
    
    Application.ScreenUpdating = True
    
    End Sub


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Re: need vba code to compare two column get result of common values of both column

    Thanks alot AB33.... works fine

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] compare A and C column if match my logic display result in B column
    By vengatvj in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 11-03-2013, 02:07 AM
  2. How to Compare Column 12 to values in column 6 while deleting dups from column 12
    By Launchnet in forum Excel Programming / VBA / Macros
    Replies: 33
    Last Post: 12-16-2011, 03:21 AM
  3. how to compare column values with a code
    By Zimmerman in forum Excel General
    Replies: 6
    Last Post: 07-02-2010, 07:49 AM
  4. [SOLVED] compare 2 lists and common ones display on the 3rd column
    By elaine in forum Excel General
    Replies: 3
    Last Post: 07-11-2006, 01:35 PM
  5. Need code to compare cell values in a column
    By Chirs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-10-2005, 06:37 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1