+ Reply to Thread
Results 1 to 2 of 2

Comparing two data sets

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-31-2013
    Location
    Philadelphia, Pa
    MS-Off Ver
    Excel 2010
    Posts
    170

    Comparing two data sets

    Hello! I'm trying to compare a data set against the master list to find a match. Once a match is found I want to copy the data in the adjacent columns back to my original list. Here is my code so far.

    Sub Find_Specific_Boxes()
    Worksheets("Full List").Select
    Range("E2").Select
    Worksheets("Other").Select
    Range("A1").Select
    
    Dim Count As Long
    Dim x As Integer
    x = ActiveSheet.UsedRange.Rows.Count
    
    For Count = 1 To x
    
        If Worksheets("Other").ActiveCell = Worksheets("Full List").ActiveCell = True Then
            Worksheets("Full List").ActiveCell.Offset(0, -4).Select
            Selection.Copy
            Worksheets("Other").ActiveCell.Offset(0, 1).Paste
            GoTo Continue
        Else
            Worksheets("Full List").ActiveCell.Offset(1, 0).Select
            GoTo Continue
        End If
    Continue:
        Next Count
        
    Range("E2").Select
    End Sub
    The data being compared begins in "A1" (on my data set) and "E2" (in my master list). If A1 doesn't match E2 I want to check it against E3 and so on until a match is found. Once the match is made I want to select columns A - D of my master list and paste it next to the corresponding match in my data set. Hopefully this all makes sense. Thanks

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Comparing two data sets

    Hi,

    I may have gotten (Have gotten?) confused - try this:

    Sub Find_Specific_Boxes() 
    Dim wf As Worksheet, wo As Worksheet
    Set wf = Worksheets("Full List")
    Set wo = Worksheets("Other")
    
    Dim Count As Long
    Dim x As Integer, y As Integer: y = 2
    x = ActiveSheet.UsedRange.Rows.Count
    
    For Count = 1 To x
    Continue:
        If wo.Range("A" & Count) = wf.Range("E" & y) Then
            wf.Range("A" & y).Copy wo.Range("B" & x)
            
        Else: y = y + 1: GoTo Continue
        End If
        y = 2: Next Count
        
    wf.Range("E2").Select
    End Sub
    Last edited by xladept; 04-01-2014 at 06:28 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ 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. Comparing two sets of data
    By redrasta in forum Excel General
    Replies: 8
    Last Post: 02-16-2012, 08:56 AM
  2. Comparing two sets of data
    By indimonk in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-12-2011, 04:03 AM
  3. Comparing 2 Sets of Data
    By gregburbidge in forum Excel General
    Replies: 13
    Last Post: 11-02-2009, 08:12 PM
  4. Comparing two sets of data
    By LEEP2008 in forum Excel General
    Replies: 7
    Last Post: 10-08-2009, 03:38 PM
  5. Comparing two sets of data
    By sheargraphix in forum Excel General
    Replies: 2
    Last Post: 06-26-2007, 01:38 PM

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