Convert Alphabet to number (a=1, b=2, etc.)

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
Is anyone aware of a funtion to return 1 for A, 2 for B, etc?

Thanks!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try:

=COLUMN(INDIRECT(A1&1))

Where A1 houses the Letter to convert.
 
Upvote 0
Sweet formula!
I should have noted this will be built into a custom function.

Is it possible something like this could be done with an array? Regards.
 
Upvote 0
Indirect() function doesn't like array formulas much....

What exactly are you trying to accomplish?
 
Upvote 0
Here's My goal:
I will be parsing a "code" that is as follows:

first digit is D or B and is a department
second digit is A thru L and is month (A=Jan, B=Feb, etc.)
third digit is G for 2007. or F for 2006, H for 2008, etc.
Fourth digit is A,B, or C for A, B, or C (easy one)
followed by a sequential numbering beginning with 001.

So: BCGA014 is B dept, March, 2007, A, 14th assigned code.

my goal is to build a custom parse function that doesn't require overmuch use of Select CASE, if possible. My standby would be to use Left, Right, and Mid type functions with good old Select Case statements.
 
Upvote 0
I'm not much of a VBA currently, so can't really help you in that department.

But...you can consider using some lookup tables containing some of these codes and associated labels.... and create a formula that "concatenates" these codes.
 
Upvote 0
NP. I played around with indirect and column for a while ... very cool :biggrin:

I came up with:
Code:
Function ParseMonth(code As String) As Byte

ParseMonth = InStr("ABCDEFGHIJKL", Mid(code, 2, 1))

End Function
If anyone sees anything wrong with my function structure let me know--this is new territory for me. Regards.
 
Upvote 0
Where I1 houses the letter you want to lookup.
=LOOKUP(I1,{"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z"},ROW(1:26))
 
Upvote 0
It's not clear to me.

What value do you want myFunction(BCGA014) to be?

Here's My goal:
I will be parsing a "code" that is as follows:

first digit is D or B and is a department
second digit is A thru L and is month (A=Jan, B=Feb, etc.)
third digit is G for 2007. or F for 2006, H for 2008, etc.
Fourth digit is A,B, or C for A, B, or C (easy one)
followed by a sequential numbering beginning with 001.

So: BCGA014 is B dept, March, 2007, A, 14th assigned code.

my goal is to build a custom parse function that doesn't require overmuch use of Select CASE, if possible. My standby would be to use Left, Right, and Mid type functions with good old Select Case statements.
 
Upvote 0

Forum statistics

Threads
1,215,044
Messages
6,122,827
Members
449,096
Latest member
Erald

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