Hi Pat
Maybe this can help out
Sub main()
Call sort_range
rowcount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
For i = 1 To rowcount
Range("a" & i).Select
firstcell = ActiveCell
firstcell = Trim(firstcell)
Range("b" & i).Select
secondcell = ActiveCell
secondcell = Trim(secondcell)
If firstcell <> secondcell Then
Selection.Insert Shift:=xlDown
End If
Next
Call reformat_column
End Sub
Sub sort_range()
rowcount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
Range("A1:A" & rowcount).Select
Range("A" & rowcount).Activate
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("B1:B" & rowcount).Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
Sub reformat_column()
On Error Resume Next
rowcount = Cells(Cells.Rows.Count, "b").End(xlUp).Row
For j = 1 To rowcount
Range("b" & j).Select
test_val_b = ActiveCell.Value
Range("a" & j).Select
test_val_a = ActiveCell.Value
If IsEmpty(test_val_a) And test_val_b > 0 Then
Range("b" & j).Select
valb_move_a = ActiveCell.Value
ActiveCell.ClearContents
ActiveCell.Offset(0, -1).Select
ActiveCell.Value = valb_move_a
End If
Next
End Sub
Bookmarks