Try this macro:
Sub test()
Dim lastr As Long, cell As Range
lastr = Cells(Rows.Count, "A").End(xlUp).Row + 1
Columns("A:A").Insert Shift:=xlToRight
Range("A1").Value = 1
Range("A1:A" & lastr).DataSeries Rowcol:=xlColumns, Type:=xlLinear, Step:=1, Trend:=False
Range("A1:X" & lastr).Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo
Columns("A:A").Insert Shift:=xlToRight
Range("A1").Value = 1
Range("A1:A" & lastr / 2).DataSeries Rowcol:=xlColumns, Type:=xlLinear, Step:=2, Trend:=False
Range("A1:Y" & lastr).Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo
For Each cell In Range("A2:A" & lastr)
If cell = "" Then cell = cell.Offset(-1, 0) + 1
Next cell
Range("A1:Y" & lastr).Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo
Columns("A:B").Delete Shift:=xlToLeft
End Sub
Hope it is easy to read that
1) in inserted columns are inserted consequtive numbers,
2) then data is sorted on name from column ex-A (now B).
3) first half (ex. A5 A1 A3 etc.) is then numbered in new column (with step 2)
4) and all data is again sorted on numbers from point 1 (original sequence resored)
5) rows with no data in column A are assigned next number after the one from above
6) everything is sorted on column A
7) no longer needed (inserted) columns A and B are deleted
Bookmarks