Sorting columns and Matching

J

Jeremy

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
 
K

Ken Johnson

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
 
Top