Extract 5 characters in a cell

exuberant

New Member
Joined
Oct 30, 2014
Messages
41
Hi,

I am trying to retrieve within a cell any 5 charactered words, numbers or alphanumeric.

Example:

1eaSsg dgsgeee 1233 122 VXC2H

i want to retrieve VXC2H. Again, it can be letters, numbers or combination of both. I just need to extract the 5 character text within a cell.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi,

I am trying to retrieve within a cell any 5 charactered words, numbers or alphanumeric.

Example:

1eaSsg dgsgeee 1233 122 VXC2H

i want to retrieve VXC2H. Again, it can be letters, numbers or combination of both. I just need to extract the 5 character text within a cell.
One example is usually not enough to decide what your question actually is. Is the text you want to retrieve always the last 5 characters in the cell? If so...

=RIGHT(A1,5)

If not, then is is the only 5 character "word" in the cell? If not, did you want to retrieve all of the 5 character "words"? If so, how are they to be displayed... all in one cell with a delimiter (say, a comma) between them or one per cell?
 
Upvote 0
One example is usually not enough to decide what your question actually is. Is the text you want to retrieve always the last 5 characters in the cell? If so...

=RIGHT(A1,5)

If not, then is is the only 5 character "word" in the cell? If not, did you want to retrieve all of the 5 character "words"? If so, how are they to be displayed... all in one cell with a delimiter (say, a comma) between them or one per cell?

Hi Rick,

It is not always at the end of the string. It can appear anywhere. There can only be 1 5 charactered word in a string.
 
Upvote 0
One example is usually not enough to decide what your question actually is. Is the text you want to retrieve always the last 5 characters in the cell? If so...

=RIGHT(A1,5)

If not, then is is the only 5 character "word" in the cell? If not, did you want to retrieve all of the 5 character "words"? If so, how are they to be displayed... all in one cell with a delimiter (say, a comma) between them or one per cell?

Sorry,

Havent answered all the queries. I want the "word" to be retrieved as a "word" in the opposite column of thr string.
 
Upvote 0
Can you make use of VBA code, namely, a UDF (user defined function)? If so...
Code:
Function FiveChars(S As String) As String
  Dim Word As Variant
  For Each Word In Split(S)
    If Len(Word) = 5 Then
      FiveChars = Word
      Exit Function
    End If
  Next
End Function

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use FiveChars just like it was a built-in Excel function. For example,

=FiveChars(A1)

If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top