This will put result in FIRST EMPTY COLUMN based on data in column with SHOE header:
Sub SHOE_Serial()
Dim mtc As Long
Dim shoe As Long
Dim LastColumn As Long
On Error Resume Next
LastColumn = ActiveSheet.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column + 1
shoe = WorksheetFunction.Match("SHOE", Range("A1:IV1"), 0)
For i = 2 To ActiveSheet.Cells(65536, shoe).End(xlUp).Row
mtc = 0
mtc = WorksheetFunction.Match(Cells(i, shoe), Range("A1:A" & i).Offset(, shoe - 1), 0)
If Cells(mtc, LastColumn).Value = 0 Then
Cells(i, LastColumn).Value = WorksheetFunction.Max(Range("A1:A" & i).Offset(, LastColumn - 1)) + 1
Else
Cells(i, LastColumn).Value = Cells(mtc, LastColumn).Value
End If
Next i
End Sub