Extract character from various string lengths

Jockeyp

New Member
Joined
Apr 24, 2021
Messages
16
Office Version
  1. 2019
Platform
  1. MacOS
Hello,

I have data that is a mix of 3 - 5 characters long contained within a cell. I want to extract each character into a new cell, and to use formulas to do it. I can use RIGHT and MID to get 3 out of the 5 out working from the right (see layout below0. The problem occurs when a cell only has 3 characters in it. Using MID just repeats the last character where I want it to be left blank.
The table below shows the output that I want to get to.

1521415214
5T445T44
TT2TT2
6134461344

My data has a miix of numbers and letters in the first cell. I have 15000 rows of data so looking for a formula to solve this for each column and leaves the blanks for less than 5 characters.

Thanks in advance

Neil
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
If they are all 3-5 characters, and you want the blanks in the beginning, and not at the end (like in your example), then use the following formulas for a value in cell A2:

Character 1:
Excel Formula:
=IF(LEN(A2)=5,LEFT(A2,1),"")

Character 2:
Excel Formula:
=IF(LEN(A2)>=4,LEFT(RIGHT(A2,4),1),"")

Character 3:
Excel Formula:
=LEFT(RIGHT(A2,3),1)

Character 4:
Excel Formula:
=LEFT(RIGHT(A2,2),1)

Character 5:
Excel Formula:
=RIGHT(A2,1)
 
Upvote 0
Solution
Here is another way to do it that is just one formula.

Assuming your value is in cell A2, and you want each of the 5 characters to appear in columns B-F,
enter this formula in cell B2 and copy across to F2:
Excel Formula:
=MID(REPT(" ",5-LEN($A2))&$A2,COLUMN()-1,1)
and then copy down for all rows.
 
Upvote 0
Another option
Fluff.xlsm
ABCDEF
1
21521415214
35T44 5T44
4TT2  TT2
56134461344
Main
Cell Formulas
RangeFormula
B2:F5B2=IFERROR(MID($A2,LEN($A2)-5+COLUMNS($B2:B2),1),"")
 
Upvote 0
Thanks Joe,

Got it working with your first solution. This forum is always really helpful.

Much appreciated.

Neil
 
Upvote 0
Excellent!
Glad we were able to help!
:)
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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