Hello everyone,
I have recently been asked to sort and match two columns of numbers. There are numbers that show up multiple times in each column. What I need is to find out which ones don't line up, and then insert either a cell in the one column. Example:
A B
11 11
22 22
33 33
33 33
33
' ' 66
My example above isn't the best as I was not able to place a space in front of the number '66'. But what I am hoping someone can help me with is anytime the two columns are equal then the compare goes to the next row. Anytime column 'A' has a greater value there is a cell inserted and then it goes to the next line to see if the two numbers match.
I have also attached an example of what I was explaining above.
If there are any questions please let me know. I also just wanted to say thank you in advance.
Welcome to the forum.
See http://www.excelforum.com/excel-gene...ting-data.html.
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
Thank you shg this is almost exactly what I needed. Problem is it only sorts the right column and if the left column has a greater number than the right column it will insert cells on the right side until it hits the end of the list on the left. Please let me know if you have any idea how to change this so it will compare both columns and then insert the cell on the side that needs to shift down. Thanks again... and thanks for the really quick response
Looks like I might have it... this is what I came up with below:
Sub lineUpalt()
Dim i As Long, lRow As Long
lRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lRow
Select Case Cells(i, 1)
Case Is < Cells(i, 2)
Cells(i, 2).Insert shift:=xlDown
Case Is > Cells(i, 2)
Cells(i, 1).Insert shift:=xlDown
Case Else
'do nothing
End Select
Next
End Sub
Last edited by techzone; 12-16-2009 at 01:07 PM. Reason: Figured out a working Macro
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks