+ Reply to Thread
Results 1 to 3 of 3

Sorting columns and Matching

  1. #1
    Jeremy
    Guest

    Sorting columns and Matching

    I am trying to sort columns so that data will match up but I am lost. Below
    is an example of what I am trying to do.

    A B C
    1
    2 2 Data Follows B
    3
    4 4 Data Follows B
    5 5 Data Follows B
    9 9 Data Follows B
    10
    15
    16 16 Data Follows B
    18
    44 44 Data Follows B
    66


    The numbers in column A are going to be in numerical or alphabetical order
    and the data in B will line up wherever it is found in A. A and B will never
    duplicate each other. C data will follow wherever B Goes. If you can help I
    would greatly appreciate it.


    Thanks
    Jeremy

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    Have a look at help for the VLOOKUP function. This might be what you need.
    Martin

  3. #3
    Ken Johnson
    Guest

    Re: Sorting columns and Matching

    Hi Jeremy,

    If you prefer a macro try this out on a backup copy of your sheet...

    Public Sub LineThemUp()
    Dim iLastRowA As Long
    iLastRowA = Range("A" & Range("A:A").Rows.Count).End(xlUp).Row
    Dim iLastRowB As Long
    iLastRowB = Range("B" & Range("B:B").Rows.Count).End(xlUp).Row
    Dim iRowA As Long
    Dim iRowB As Long
    For iRowA = iLastRowA To 1 Step -1
    For iRowB = iLastRowB To 1 Step -1
    If Cells(iRowB, 2).Value = Cells(iRowA, 1).Value Then
    Let Range(Cells(iRowA, 2), Cells(iRowA, 3)).Value = _
    Range(Cells(iRowB, 2), Cells(iRowB, 3)).Value
    Range(Cells(iRowB, 2), Cells(iRowB, 3)).ClearContents
    Exit For
    End If
    Next iRowB
    Next iRowA


    Ken Johnson


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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