Excel String Function (Text Function)
Edit
A friend called me for help on excel today. He asked me if these could be done in excel
1. extract the first 4 digits of a phone number on 9 thousands records
2. extract the first part of the email (the part before "@" sign) on the same 9 thousands records
The first one is easy. After spending 30 sec searching and reading the Excel Text Function list, I found the "LEFT" function to use. So insert a new cell and type in the formula "=LEFT(A1,4)" assuming A1 is the original cell containing the phone number
The 2nd one is a bit tricky, I was hoping the "REPLACE" function in excel will accept "*" as wildcard, so that I can replace anything with "@*". But turns out it didn't accept usage like that. So I have to find another solution. I then approach it differently by using the "FIND" function to locate the index of "@" sign in the string and I use the "LEFT" function again to extract the first part in the email. So in a new cell, type the formula "=LEFT(B1,FIND("@",B1)-1)" , that is assuming B1 holds the value of the original email address
Reference : Text functions
1. extract the first 4 digits of a phone number on 9 thousands records
2. extract the first part of the email (the part before "@" sign) on the same 9 thousands records
The first one is easy. After spending 30 sec searching and reading the Excel Text Function list, I found the "LEFT" function to use. So insert a new cell and type in the formula "=LEFT(A1,4)" assuming A1 is the original cell containing the phone number
The 2nd one is a bit tricky, I was hoping the "REPLACE" function in excel will accept "*" as wildcard, so that I can replace anything with "@*". But turns out it didn't accept usage like that. So I have to find another solution. I then approach it differently by using the "FIND" function to locate the index of "@" sign in the string and I use the "LEFT" function again to extract the first part in the email. So in a new cell, type the formula "=LEFT(B1,FIND("@",B1)-1)" , that is assuming B1 holds the value of the original email address
Reference : Text functions
Excel String Function (Text Function)
Reviewed by DF
on
8:39:00 PM
Rating: