Search This Blog

Thursday, August 18, 2011

How do I extract selected text from a string of text?

Data in a cell and need to extract part of it :


Examples:
1. AERO 030405A AUTO 24567AZ 99AM  > Extract 67
2. AERO 030405Z AUTO 25611C22AZ 99BM >  Extract 11 




Solution:
1.
=IF(ISERROR(FIND("C",Sheet1!A1)),MID(Sheet1!A1, FIND("AZ",Sheet1!A1)-2, 2),MID(Sheet1!A1, FIND("G",Sheet1!A1)-2, 2))

2.
=IF(ISERROR(FIND("AZ",Sheet1!A2)),MID(Sheet1!A2, FIND("G",Sheet1!A2)-2, 2),MID(Sheet1!A2, FIND("C",Sheet1!A2)-2, 2))

   

No comments:

Post a Comment