Find/replace sequence range of numbers 1-10

aleon

New Member
Joined
Oct 17, 2018
Messages
19
Hi all,

New to the forums, keep up the good work.

Getting stuck on getting a cell with a value of 1-10, separated out into its individual values i.e 1,2,3,4,5,6,7,8,9,10
Another example is 50-60 again, i want to separated the values out like: 50,51,52... and so on...

Can anyone help?

I managed to get some info how it might be possible, but gettig stuck on a working formula in Excel 2016.

Code:
<code>=SUBSTITUTE(TRIM(CONCAT(ROW(INDIRECT(LEFT(A1,FIND("-",A1)-1)&":"&MID(A1,FIND("-",A1)+1,999)))&" "))," ",",")</code>

Excel complains on the <code>A1,FIND portion where trying to find values separated by a hyphen =-=

Hoe someone can help?

Thanks very much.
</code>
 
Unfortunately this expression/function just returns what is the difference (subtraction) between the number sin the range.
i.e. 123456789-123456799

10
The technique Peter used in his code was to make the numbers on either side of the dash row numbers and let Excel generate the list; however, those numbers are larger than what any row number can be. I think this UDF (user defined function should work correctly for you...
Code:
[table="width: 500"]
[tr]
	[td]Function Seq(sLimits As String, Optional sDelimiter As String = ",") As Variant
  Dim Prefix As String, ReCombo As String, S As Variant, Parts As Variant
  For Each S In Split(Replace(sLimits, " ", ""), ",")
    If InStr(S, "-") Then
      Parts = Split(S, "-")
      If Len(Parts(0)) > 6 Then
        Parts = Split(S, "-")
        Prefix = Left(Parts(0), Len(Parts(0)) - 6)
        Parts(0) = "A" & Mid(Parts(0), Len(Parts(0)) - 5)
        If UBound(Parts) = 1 Then Parts(1) = "A" & Mid(Parts(1), Len(Parts(1)) - 5)
      End If
      S = Join(Evaluate("TRANSPOSE(ROW(" & Join(Parts, ":") & "))"), sDelimiter)
      If Len(Prefix) Then S = Prefix & Replace(S, sDelimiter, sDelimiter & Prefix)
    End If
    Seq = Seq & sDelimiter & S
  Next
  Seq = Mid(Seq, Len(sDelimiter) + 1)
End Function[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi @Rick Rothstein

Thanks for your advise and input into this. Sorry has taking this long for me to respond, didn't get the alert of a new response to this thread.

Have tried your UDF and works fine with range of number 0123-1234 (4-digits) long but if its 5,6 or higher number of digits long the UDF can transpose these number, example: 78934-78937 get #VALUE ! response back.

Much appreciated you and everyone else response, excel is powerful tool if you know how too utilize its calcualtion power :)

Thanks
 
Last edited:
Upvote 0
OK Thanks Rik, might be problem with Excel version in use my end then.
Will keep trying and saving/re-saving file in old/new versions see if i can find a working pattern for me and post here.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,111
Messages
6,128,899
Members
449,477
Latest member
panjongshing

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top