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

Nitesh Singh picture Nitesh Singh · Jul 12, 2012 · Viewed 249.9k times · Source

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?

Answer

ApplePie picture ApplePie · Jul 12, 2012

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))