Text Length Conversion

Tikey

Board Regular
Joined
Jan 30, 2014
Messages
148
Office Version
  1. 2021
Platform
  1. Windows
I am currently using several stages to achieve my goal andwonder whether there is a more efficient way to do this, hopefully just in onecell.

I have a cell which contains letters and numbers which canbe between 6 and 12 characters long and for cells which contain more than 6, Iwish to be able to select certain characters. My current method is:

In cell A1 - SE1553346646
In cell B1 – I then convert to show many charters A1contains with =LEN(A1), in this case 12
In cell C1 – I always want the first 4 characters so I amusing =MID(A1,1,4), giving SE15
In cell D1 – As the other characters could be at various positionsdepending on how many characters are in A1 I am using a nested IF statement , =IF(B1=6,MID(A1,5,2),IF(B1=8,MID(A1,6,2),IF(B1=10,MID(A1,7,2),IF(B1=12,MID(A1,8,2))))),in this case giving 46
In cell E1 – I then use =C1&D1 to provide my final answerof SE1546

Is there a better more efficient way to do this, can it beachieved within one cell ?

Thanks
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
How about
=LEFT(A6,4) & MID(A6,CHOOSE(LEN(A6),,,,,,5,,6,,7,,8),2)
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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