View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default replace dash in a number sequence

Select the cells containing the data and run:

Sub ListMaker()
Dim n1 As Integer, n2 As Integer
Dim v As String
For Each r In Selection
s = Split(r.Value, "-")
n2 = s(1)
n1 = Right(s(0), Len(s(0)) - 1) + 1
v = s(0)
For i = n1 To n2
v = v & "," & i
Next
r.Value = v
Next
End Sub
--
Gary''s Student - gsnu200769


"Willy Wonka" wrote:

I've got a cell that represents a sequence of numbers like p129-132 and would
like to list each number seperately: p129,p130,p131,p132.

TIA