On the basis you want each set in a different cell, try this.
Results start "A5"
Sub MG08Nov37
Dim Lst As Long, n As Long
Dim Str As String, Sp As Variant
Dim nSp As Variant
Lst = Cells("1", Columns.Count).End(xlToLeft).Column
For n = 1 To Lst
If n = 1 Then
Str = Cells(1, n)
ElseIf Cells(1, n) = Cells(1, n - 1) + 1 Then
Str = Str & "#" & Cells(1, n)
Else
Str = Str & "," & Cells(1, n)
End If
Next n
Sp = Split(Str, ",")
For n = 0 To UBound(Sp)
If InStr(Sp(n), "#") Then
nSp = Split(Sp(n), "#")
Sp(n) = nSp(0) & "-" & nSp(UBound(nSp))
End If
Next n
With Range("A5")
.EntireRow.Clear
.Resize(, UBound(Sp) + 1) = Sp
End With
End Sub
Regards Mick
Bookmarks