Modifying numbers from one long string into 2 shorter strings

virtuosok

Board Regular
Joined
Sep 2, 2020
Messages
209
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have a set of numbers in a column in the following format (3 digits, dash, 5 digits):
002-00001
036-01009
153
-99182
Let's assume, this is range A2:A1000. For me, meaningful are only the first 3 digits and the last 3 digits (excluding any leading zeros). How do I:
- split these 2 pieces into 2 separate columns (e.g. B2:B1000 and C2:C:1000) and
- lose any leading zeros?
In other words, the output I seek would look as follows

21
369
153182

Thanks :)
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You can use Text To Columns on the data tab for that. In the first step choose Fixed length rather than delimited, then in the second step click after the first three digits then again before the last three (that should give you three columns) then in the last step select the second column and choose Do not import, then Finish.
 
Upvote 0
You can use Text To Columns on the data tab for that. In the first step choose Fixed length rather than delimited, then in the second step click after the first three digits then again before the last three (that should give you three columns) then in the last step select the second column and choose Do not import, then Finish.
Thanks! This doesn't seem to work for me unfortunately, likely because the source column is not formatted as text (or numbers) but being an extract from other column. How do I need to convert please?
 

Attachments

  • Capture.PNG
    Capture.PNG
    4.6 KB · Views: 5
Upvote 0
Another option would be to select B2:B?? and use Data ribbon tab -> Text to columns -> Fixed width -> Next
Click to insert the column dividers after 3 and before last 3
1600080200181.png

-> Next -> Select the Destination top cell, click in middle column and choose 'Do not import column'
1600080352044.png


-> Finish

20 09 14.xlsm
BCD
1
2002-0000121
3036-01009369
4153-99182153182
5
TTC
 
Upvote 0
Isn't that what I said in post 2, Peter? ;)
 
Upvote 0

Forum statistics

Threads
1,215,062
Messages
6,122,925
Members
449,094
Latest member
teemeren

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