Sub AirFreightReferrals() 'Jacek Jarecki Air Freight Referrals' 'tested on vba 2007 excell' 'set variables Dim myColumns As Variant Dim x As Variant Dim findfield As Variant Dim currentColumn As Integer Dim columnHeading As String Dim oCell As Range Dim iNum As Long Dim iRow As Integer '********************************************************************************************************************* '********************************************************************************************************************* 'type columns you want(using headers) in order you like myColumns = Array("customer_code", "invoice_number", "dealer_pick_pack_code", "part_description", "finis_code", "pieces_shipped") '<---YOU CAN EDIT '********************************************************************************************************************* '********************************************************************************************************************* 'STEP ONE:_______________KEEP YOUR COLUMNS AND REARRANGE For x = LBound(myColumns) To UBound(myColumns) ' from the lowest index in array to the highest findfield = myColumns(x) iNum = iNum + 1 Set oCell = ActiveSheet.Rows(1).Find(What:=findfield, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) If Not oCell.Column = iNum Then Columns(oCell.Column).Cut Columns(iNum).Insert Shift:=xlToRight End If Next x 'STEP TWO:_______________DELETE THE REST of COLUMNS For currentColumn = ActiveSheet.UsedRange.Columns.Count To (UBound(myColumns) + 2) Step -1 'UsedRange - how many columns in use ActiveSheet.Columns(currentColumn).Delete Next currentColumn 'STEP THREE:_______________SORT COLUMNS C and E ( !!! if you rearrange change colums to sort as well) ActiveSheet.sort.SortFields.Clear ActiveSheet.sort.SortFields.Add Key:=Range("C2:C9999"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal ActiveSheet.sort.SortFields.Add Key:=Range("E2:E9999"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveSheet.sort .SetRange Range("A1:Z999") .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With 'STEP FOUR:_______________MAKE SPACES BETWEEN COUNTRIES Range("a1").Select iRow = 1 Do If Cells(iRow + 1, 1) <> Cells(iRow, 1) Then 'insert row' Cells(iRow + 1, 1).EntireRow.Insert Shift:=xlDown Cells(iRow + 1, 1).Range("A1").RowHeight = 4 'create lines (using loop)' Dim index As Integer index = 1 Do While index <= 6 Cells(iRow + 1, index).Interior.ColorIndex = 15 index = index + 1 Loop iRow = iRow + 2 Else iRow = iRow + 1 End If Loop While Not Cells(iRow, 1).Text = "" 'STEP FOUR:_______________A BIT STYLES Columns("D").HorizontalAlignment = xlHAlignRight 'align column 4(or "D")' Columns("F").HorizontalAlignment = xlHAlignLeft 'align "f"' Columns("D").ColumnWidth = 35 'set the width of column' Columns("E").ColumnWidth = 12 'set the width of column' End Sub