Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Excel, how do I extract last four letters of a ten letter string?

Tags:

For example, if I have

ABS YUR YUAO   
HFH IWO OQNX  
YQO PQM QUCC

How do I extract the last four letters in another column?

like image 251
Nitesh Singh Avatar asked Jul 12 '12 01:07

Nitesh Singh


1 Answers

No need to use a macro. Supposing your first string is in A1.

=RIGHT(A1, 4)

Drag this down and you will get your four last characters.

Edit: To be sure, if you ever have sequences like 'ABC DEF' and want the last four LETTERS and not CHARACTERS you might want to use trimspaces()

=RIGHT(TRIMSPACES(A1), 4)

Edit: As per brettdj's suggestion, you may want to check that your string is actually 4-character long or more:

=IF(TRIMSPACES(A1)>=4, RIGHT(TRIMSPACES(A1), 4), TRIMSPACES(A1))
like image 98
ApplePie Avatar answered Sep 21 '22 02:09

ApplePie