1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37:
Function MakeTheList(ArrayIn As Variant) Dim x As Variant Dim StartAt As Long, EndAt As Long Dim Counter As Long Const Delimiter As String = ", " For Each x In ArrayIn Counter = Counter + 1 If x <> 0 Then EndAt = Counter If StartAt = 0 Then StartAt = Counter Else If EndAt <> 0 Then If StartAt <> EndAt Then MakeTheList = MakeTheList & Delimiter & StartAt & "-" & EndAt Else MakeTheList = MakeTheList & Delimiter & StartAt End If StartAt = 0 EndAt = 0 End If End If Next If StartAt <> 0 Then If StartAt <> EndAt Then MakeTheList = MakeTheList & Delimiter & StartAt & "-" & EndAt Else MakeTheList = MakeTheList & Delimiter & StartAt End If End If MakeTheList = Mid(MakeTheList, Len(Delimiter)) End Function