You could use the Text to columns function. If all date is in col A select Col a the text to columns under Data < Data Tools on ribbon. Select Radio button "Delimited" Other - enter dash. Next brings up Format options which here will default to general which is numbers. Finish. This will separate the data into A & B columns.
Now sort by column A and in column C input =A1&"-"&B1 which now gives your original data in the form you require.
I couldn't figure out a way to do it with a formula but I'm sure it can be done. I was stumped by the three or four digits before the dash.
I recorded a macro
Sub Macro2()
'
' Macro2 Macro
'
' Keyboard Shortcut: Ctrl+s
'
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="-", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Columns("A:B").Select
ActiveWorkbook.Worksheets("Sheet5").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet5").Sort.SortFields.Add Key:=Range("A1:A7"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet5").Sort
.SetRange Range("A1:B7")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("C1").Select
ActiveCell.FormulaR1C1 = "=RC[-2]&""-""&RC[-1]"
Range("C1").Select
Selection.AutoFill Destination:=Range("C1:C7"), Type:=xlFillDefault
Range("C1:C7").Select
End Sub
Bookmarks