Extract First Digit from Alphanumeric Number

vikrampnz

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

I have a list of alphanumeric values in a column as below:

B-101
B-102
B-103
B-904
B-806
B-1005
B-1103
and so on. Effectively, these represent floor numbers... i.e. 101 means "1" floor, 1103 means "11" Floor etc. I want to automatically get floor number next to the unit numbers in a separate column.

Is there a formula in excel where I can extract first digit from a 3 digit alphanumeric value e.g. B-904 - I want to extract "9" in the adjacent column. Similar first 2 digits from a value with 4 digits e.g. B-1005 - I want to extract "10". In other words, I want to extract the digit/s excluding the last two digits.

I have tried the formula to convert the Alphanumeric value to Number i.e. I can convert B-1005 to 1005 using the formula:
VBA Code:
=RIGHT(A2, LEN(A2) - SEARCH("-", A2)) *1
. But unable to differentiate between 1,10 & 11.

I would appreciate any help offered.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
How about
Fluff.xlsm
AB
1
2B-1011
3B-1021
4B-1031
5B-9049
6B-8068
7B-100510
8B-110311
Sheet5
Cell Formulas
RangeFormula
B2:B8B2=MID(A2,3,LEN(A2)-4)
 
Upvote 0
Slightly longer formula but a bit more flexible:

Book1
ABC
1B-1011
2B-1021
3B-1031
4B-9049
5B-8068
6B-100510
7B-110311
8AB-1421
9ABC-114211
10
Sheet1
Cell Formulas
RangeFormula
B1:B9B1=MID(A1,FIND("-",A1)+1,LEN(A1)-FIND("-",A1)-2)
 
Upvote 0
An alternative with Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Added Custom Column" = Table.AddColumn(Source, "Custom", each let splitColumn1 = Splitter.SplitTextByDelimiter("-", QuoteStyle.None)([Column1]) in Text.Reverse(Text.Middle(Text.Reverse(splitColumn1{1}?), 2)), type text)
in
    #"Added Custom Column"
 
Upvote 0
@alansidman I don't believe Power Query is available for Excel 2007 that the OP is showing as the current Excel version. :(
 
Upvote 0
@johnnyL
True, and yet the OP has not acknowledged any post here and in particular the question asked in Post #2 by Sufiyan97. The OP has been a member here since 2006. Perhaps he has upgraded.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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