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>
 
Peter_SSs
Using your Seq formula is it possible to extrapolate the series of number from the same cells when it also contains multiple series + individual numbers in the mix?

For example:
A1 = 1,2,3, 5-20, 100,101,102, 700-708

and thx for the welcome :)
 
Last edited:
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Peter_SSs
Using your Seq formula is it possible to extrapolate the series of number from the same cells when it also contains multiple series + individual numbers in the mix?

For example:
A1 = 1,2,3, 5-20, 100,101,102, 700-708
Sure, try this function.

Code:
Function MultiSeq(sLimits As String, Optional sDelimiter As String = ",") As String
  Dim s As Variant
  
  For Each s In Split(Replace(sLimits, " ", ""), ",")
    MultiSeq = MultiSeq & sDelimiter & Join(Application.Transpose(Evaluate("row(" & Join(Application.Index(Split(s & "-" & s, "-", 3), 1, Array(1, 2)), ":") & ")")), sDelimiter)
  Next s
  MultiSeq = Mid(MultiSeq, Len(sDelimiter) + 1)
End Function

Excel Workbook
AB
11,2,3, 5-20, 100,101,102, 700-7081,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,100,101,102,700,701,702,703,704,705,706,707,708
Multiple Sequences
 
Upvote 0
Hi Peter,

Hope you dont mind me asking again, keep asking questions here :)

From your formula above how can I extend the number of digits that can be extrapolated?

I mean, if the number(s) or ranges within a cell are 10-digits/or longer, how can I update "function" to deal with these longer numbers, as I think if its more than 6-digits its ignored by "function".

Thanks once again, appreciate you expert advise on this.
 
Upvote 0
Code:
[table="width: 500"]
[tr]
	[td]Function Seq(sLimits As String, Optional sDelimiter As String = ",") As Variant
  Seq = Join(Application.Transpose(Evaluate("row(" & Replace(sLimits, "-", ":") & ")")), sDelimiter)
End Function[/td]
[/tr]
[/table]
Is there an advantage to using Application.Transpose rather than embedding TRANSPOSE directly inside the Evaluate function call?
Code:
[table="width: 500"]
[tr]
	[td]Function Seq(sLimits As String, Optional sDelimiter As String = ",") As Variant
  Seq = Join(Evaluate("TRANSPOSE(ROW(" & Replace(sLimits, "-", ":") & "))"), sDelimiter)
End Function[/td]
[/tr]
[/table]
 
Upvote 0
Peter_SSs
Hoping this tag works and can help again :)
I'm sorry, I haven't been able to spend time on the forum for a while and that will continue for a while longer. Perhaps Rick or somebody else might be able to help.
 
Upvote 0
Thank you both for continue support.
Appreciate the time, we all have busy lives and not that we get paid for this.

But thank you!

Will try out your version @Rick Rothstein
 
Upvote 0
Unfortunately this expression/function just returns what is the difference (subtraction) between the number sin the range.
i.e.
123456789-123456799
10

<tbody>
</tbody>

Is there an advantage to using Application.Transpose rather than embedding TRANSPOSE directly inside the Evaluate function call?
Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Function Seq(sLimits As String, Optional sDelimiter As String = ",") As Variant
  Seq = Join(Evaluate("TRANSPOSE(ROW(" & Replace(sLimits, "-", ":") & "))"), sDelimiter)
End Function[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,107
Messages
6,128,869
Members
449,475
Latest member
Parik11

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