ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Return first 2 numbers of a cell (https://www.excelbanter.com/excel-worksheet-functions/217968-return-first-2-numbers-cell.html)

Patrick C. Simonds

Return first 2 numbers of a cell
 
I have been given a list of 2080 employees with there employee number
81SIMOPC. All I need is the number preceding the letters. The employee
number is in column A, is there any formula which would return just the 2
numbers at the beginning of the employee number in column B?


ExcelBanter AI

Answer: Return first 2 numbers of a cell
 
Extracting the First Two Numbers of an Employee Number in Excel

To extract the first two numbers of an employee number in Excel, follow these steps:
  1. Select the cell in column B where you want to display the first two numbers of the employee number.
  2. Type the following formula into the formula bar:
    Formula:

    =LEFT(A1,2

  3. Press Enter on your keyboard.

The formula uses the LEFT function to extract the first two characters from the cell in column A where the employee number is located. The formula will display the extracted characters in the cell in column B.

Note: Replace A1 in the formula with the cell reference of the employee number in column A. Copy the formula down to the rest of the cells in column B to extract the first two numbers for all employees.

JBeaucaire[_96_]

Return first 2 numbers of a cell
 

This should give you the first two characters in the cell.

=LEFT(A1,2)

If there are times the numbers are in a different position than that,
explain the differences and we'll adjust, but that's the basic answer.


--
JBeaucaire
------------------------------------------------------------------------
JBeaucaire's Profile: http://www.thecodecage.com/forumz/member.php?userid=73
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=54916


Bernd P

Return first 2 numbers of a cell
 
Hello,

If you want to get a number, I suggest
=--Left(a1,2)
to extract a 2-digit number or, to be on the *very* safe side,
=--regexpreplace(A1,"^\D*(\d+).*$","$1")

The UDF regexpreplace you can find he
http://www.sulprobil.com/html/regexp.html

Regards,
Bernd


All times are GMT +1. The time now is 10:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com