Option Explicit
Sub LineThemUp()
'JBeaucaire 2/16/2010
'Lines up values in columns B, O, AB and AL
Dim LR As Long
Application.ScreenUpdating = False
LR = Range("A" & Rows.Count).End(xlUp).Row
'Create a unique list of all values
Range("B3:B" & LR).Copy Range("DD1")
Range("O4:O" & LR).Copy Range("DD" & Rows.Count).End(xlUp).Offset(1, 0)
Range("AB4:AB" & LR).Copy Range("DD" & Rows.Count).End(xlUp).Offset(1, 0)
Range("AL4:AL" & LR).Copy Range("DD" & Rows.Count).End(xlUp).Offset(1, 0)
Range("DD:DD").SpecialCells(xlCellTypeBlanks).Delete xlShiftUp
Range("DD:DD").Sort [DD1], xlAscending, , , , , , xlYes
LR = Range("DD" & Rows.Count).End(xlUp).Row
Range("DD1:DD" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("DE3"), Unique:=True
Range("DD:DD").Clear
'Filter out the blanks
Range("A3:M" & LR).Sort Key1:=Range("B4"), Order1:=xlAscending, Header:=xlYes
Range("N3:Z" & LR).Sort Key1:=Range("O4"), Order1:=xlAscending, Header:=xlYes
Range("AA3:AJ" & LR).Sort Key1:=Range("AB4"), Order1:=xlAscending, Header:=xlYes
Range("AK3:AT" & LR).Sort Key1:=Range("AL4"), Order1:=xlAscending, Header:=xlYes
Dim i As Long: i = 4
Do
If Cells(i, "B") > Cells(i, "DE") Then _
Range(Cells(i, "A"), Cells(i, "M")).Insert xlShiftDown
If Cells(i, "O") > Cells(i, "**") Then _
Range(Cells(i, "N"), Cells(i, "Z")).Insert xlShiftDown
If Cells(i, "AB") > Cells(i, "DE") Then _
Range(Cells(i, "AA"), Cells(i, "AJ")).Insert xlShiftDown
If Cells(i, "AL") > Cells(i, "DE") Then _
Range(Cells(i, "AK"), Cells(i, "AT")).Insert xlShiftDown
i = i + 1
Loop Until Cells(i, "DE") = ""
Range("DE:DE").Clear
Application.ScreenUpdating = True
MsgBox "Complete"
End Sub
Bookmarks