Can anyone suggest a more efficient way of ordering two columns so that the same values are on the same row?
column M has 16000 filled cells and column P has up to 50 filled cells, so my loop's really slow. For each cell in col P I need to move it to the p cell adjacent to its match in col M.
so I want:
1 2
2 7
3 9
4
5
6
7
8
9
to be:
1
2 2
3
4
5
6
7 7
8
9 9
Thanks!
Sub lloop() Application.ScreenUpdating = False Dim lcounter As Long lcounter = 2 'set this to the first row number Do While Range("M" & lcounter).Value <> "" And Range("P" & lcounter).Value <> "" If Range("M" & lcounter).Value <> Range("P" & lcounter) Then If Range("M" & lcounter).Value < Range("P" & lcounter) Then Range("P" & lcounter).Insert Shift:=xlDown End If End If lcounter = lcounter + 1 Loop Application.ScreenUpdating = True End Sub
Bookmarks