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>
 
If you are on UK regional setting semi-colons are not the problem
You can prove it by entering any value into A1 and putting this formula in any cell
=MID(A1,1,1)
If the formula returns anything then commas are ok in your formula

I will get there one day, I hope :smile:
I am glad you are a glass-half-full type!

Did you try...
in A1 entering..
'1-10
and in B1 this formula..
=SUBSTITUTE(TRIM(CONCAT(ROW(INDIRECT(LEFT(A1,FIND("-",A1)-1)&":"&MID(A1,FIND("-",A1)+1,999)))&" "))," ",",")

PLEASE copy and paste EVERYTHING from here as I know this works
 
Last edited:
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
If that fails
Ensure that A1 contains..
'1-10 (including apostrophe)
and then in B1 enter this formula..
=FIND("-",A1)

B1 returns a number
 
Last edited:
Upvote 0
If that fails
Ensure that A1 contains..
'1-10 (including apostrophe)
and then in B1 enter this formula..
=FIND("-",A1)

B1 returns a number


Thanks again Yongle, still problem accepting the new array function from your previous post or even the simplified version as you can see form screenshot.

Excel 2016 flags up another error.
https://imgur.com/a/T0FgMuP
T0FgMuP


My colleague also trie don his own machine and get same problems.
This is really weird...

So am gona try on another machine which hopefully has older version of excel i can try.
 
Upvote 0
I believe that the CONCAT function is only available with a 365 subscription.
 
Upvote 0
I believe that the CONCAT function is only available with a 365 subscription.
Thanks Fluff.
Have now updated the formula to replace CONCAT to CONCATENATE

Code:
=SUBSTITUTE(TRIM(CONCATENATE(ROW(INDIRECT(LEFT(A1;FIND("-";A1)-1)&":"&MID(A1;FIND("-";A1)+1;999)))&" "));" ";",")

This partly works, but only shows first character int he series of number, in this case just 1.
 
Last edited:
Upvote 0
Have now updated the formula to replace CONCAT to CONCATENATE
CONCATENATE requires you to enter individually all the values to be concatenated & all the delimiters, so I don't think it is going to meet your needs.

You mentioned excel 2016 in your first post but if you have that but not CONCAT or TEXTJOIN then it must be a stand-alone version of Office, not Office 365.
If you don't have the CONCAT function (or this could be done with a shorter formula using TEXTJOIN but that function also required Office 365) then ..

I would suggest that you consider a user-defined function. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. In the Visual Basic window use the menu to Insert|Module
3. Copy and Paste the code below into the main right hand pane that opens at step 2.
4. Close the Visual Basic window.
5. Enter the formula as shown in the screen shot below and copy down.
6. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm)

Code:
Function Seq(sLimits As String, Optional sDelimiter As String = ",") As Variant
  Seq = Join(Application.Transpose(Evaluate("row(" & Replace(sLimits, "-", ":") & ")")), sDelimiter)
End Function

Note that the function offers an optional different delimiter as shown in cell C2 (though for your language version you may need to use a semicolon =Seq(A2;"|")

Excel Workbook
ABC
11-101,2,3,4,5,6,7,8,9,10
250-6050,51,52,53,54,55,56,57,58,59,6050|51|52|53|54|55|56|57|58|59|60
Sequence
 
Last edited:
Upvote 0
@Peter_SSs

Thats excellent, this works for me :)

I am using MS Office Professional Plus 2016 MSO (16.0.4738.1000) 32-bit. Working with it on a Win 10 64-bit Laptop.

Thank you very much, also thanking everyone else involved in this thread, much appreciated your advise.
 
Upvote 0
No problem. Glad to help.

BTW, Welcome to the MrExcel board! :)


For other readers, here it is with the TEXTJOIN function

Excel Workbook
AB
11-101,2,3,4,5,6,7,8,9,10
250-6050,51,52,53,54,55,56,57,58,59,60
Sequence
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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