Extract first 3 characters & first 4 characters from a alphanumeric value

vikrampnz

Board Regular
Joined
Jun 20, 2006
Messages
111
Office Version
  1. 2007
Platform
  1. Windows
Hello

I have a list that looks like this in column B:

B-101
B-404
B-602
B-905
B-1003
B-1106 and so on.

I am trying to extract first 3 characters in case where the value has 5 characters and first 4 characters in cases where the value has 6 characters in another column.

For example:

Column B Column C
B-101 >>>>> B-1
B-404 >>>>> B-4
B-602 >>>>> B-6

B-1003 >>>>> B-10
B-1106 >>>>> B-11

I am using following formula:

Excel Formula:
=LEFT(B3,2*(LEFT((RIGHT(B3,LEN(B3)-SEARCH("-",B3))*1),LEN(RIGHT(B3,LEN(B3)-SEARCH("-",B3))*1)-2)))

I am getting "B-", but not the numbers after "-".

Can someone please help? I would appreciate any help.

Thanks
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Two other options
Fluff.xlsm
ABCD
1
2B-101B-1B-1
3B-404B-4B-4
4B-602B-6B-6
5B-905B-9B-9
6B-1003B-10B-10
Sheet4
Cell Formulas
RangeFormula
C2:C6C2=LEFT(B2,3+(LEN(B2)=6))
D2:D6D2=SUBSTITUTE(B2,RIGHT(B2,2),"")
 
Upvote 0
Solution
Thank you so much Fluff !! It did the trick !!
I assume that you mean the first formula?
The second formula could fail depending on the column B values - see post #6 column D which shows the same formula with some incorrect results.
 
Upvote 0
Hello Peter _SSs

I did not use the second formula. I used the first formula and it worked well.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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