PDA

View Full Version : Mega Sort



daniels012
10-14-2009, 01:24 PM
My Column A has names
My column D has names
Every name that is in A is sorted properly
I need to get Column D's names to align with Column A, BUT! I need D,E, And F to move all together.

A1 has Bob
A2 has Tom
A3 has Dave
D1 has Dave E1 has HUJ F1 has 25
D2 has Bob E2 has GER F2 has 28
D3 has Tom E3 has PLS F3 has 0

The result I would like is:
A1 has Bob D1 has Bob E1 has GER F1 has 28
A2 has Tom D2 has Tom E2 has PLS F2 has 0
etc. etc.

I need code that can align/sort the names but bring the E and F column along with it.

Is there code that can be written to accomplish this?

Thank You in advance,
Michael

Bob Phillips
10-14-2009, 02:30 PM
Public Sub ProcessData()
Dim i As Long
Dim LastRow As Long

With ActiveSheet

.Columns("D").Insert
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("D1").Resize(LastRow)

.Formula = "=MATCH(E1,A:A,0)"
.Value = .Value
End With

.Range("D1").Resize(LastRow, 4).Sort key1:=.Range("D1"), order1:=xlAscending, Header:=xlNo
.Columns("D").Delete
End With

End Sub