ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sorting columns and Matching (https://www.excelbanter.com/excel-discussion-misc-queries/100500-sorting-columns-matching.html)

Jeremy

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

mrice

Sorting columns and Matching
 

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


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=563567


Ken Johnson

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



All times are GMT +1. The time now is 02:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com