You can use the following formulas in Excel to find the first number in a text string:
Formula 1: Return Position of First Number
=MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))
This formula returns the position of the first number in a string.
For example, if the string is A0095B then this formula will return 2 since this is the position in the string where the first number occurs.
Formula 2: Return Value of First Number
=MID(A2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789")),1)
This formula returns the value of the first number in a string.
For example, if the string is A0095B then this formula will return 0 since this is the value of the first number that occurs in the string.
The following example shows how to use each formula in practice with the following list of employee ID strings in Excel:
Example 1: Return Position of First Number
We can type the following formula into cell B2 to return the position of the first number in each Employee ID text string:
=MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))
We can then click and drag this formula down to each remaining cell in column B:
Column B returns the position of the first number in each corresponding string in column A.
For example:
- The first number in A0095B occurs in position 2 of the string.
- The first number in 43387BR occurs in position 1 of the string.
- The first number in BCDD7D occurs in position 5 of the string.
And so on.
Example 2: Return Value of First Number
We can type the following formula into cell B2 to return the value of the first number in each Employee ID text string:
=MID(A2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789")),1)
We can then click and drag this formula down to each remaining cell in column B:
Column B returns the value of the first number in each corresponding string in column A.
For example:
- The value of the first number in A0095B is 0.
- The value of the first number in 43387BR is 4.
- The value of the first number in BCDD7D is 7.
And so on.
Additional Resources
The following tutorials explain how to perform other common tasks in Excel:
How to Count Duplicates in Excel
How to Count Frequency of Text in Excel
How to Count by Group in Excel