ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Sorting 2 colums to get numbers to match ? (https://www.excelbanter.com/excel-worksheet-functions/169335-sorting-2-colums-get-numbers-match.html)

thriller

Sorting 2 colums to get numbers to match ?
 
example:
101 105 101
102 107 102
103 103
104 104
105 105 105
106 106
107 107 107




--
688

ryguy7272

Sorting 2 colums to get numbers to match ?
 
I think this will do what you want (but it only works on two columns; A and B):

Sub Matching_Cell()
Dim rng As Range, cell As Range
Set rng = Range(Range("A1"), Range("A65536").End(xlUp))
Application.ScreenUpdating = False
For Each cell In rng
With cell
If .Offset(0, 1) = "" Then Exit For
If .Value < .Offset(0, 1).Value Then
..Offset(0, 1).Insert
ElseIf .Value .Offset(0, 1).Value Then
..Insert
End If
End With
Next
End Sub


Regards,
Ryan---


--
RyGuy


"thriller" wrote:

example:
101 105 101
102 107 102
103 103
104 104
105 105 105
106 106
107 107 107




--
688


Max

Sorting 2 colums to get numbers to match ?
 
This might work as well
Assuming source data in cols A and B as posted, from row1 down
In C1:
=IF(ISNUMBER(MATCH(A1,B:B,0)),A1,"")
Copy C1 down to the last row of data in col A
Col C returns the aligned results that you seek for the values in col B
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"thriller" wrote:
example:
101 105 101
102 107 102
103 103
104 104
105 105 105
106 106
107 107 107




--
688



All times are GMT +1. The time now is 03:50 PM.

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