Extract letters from cell

Fin Fang Foom

Well-known Member
Joined
Mar 20, 2005
Messages
598
Hi everyone,



I would like a formula to extract all letters in a cell but in that cell it also has numbers. I would like to extract the letters only.


Example:
HYPHEN2.xls
ABCD
1Extract letters
21f2d4g1g56gfdggg
3z1g5gzgg
4\g1h5gfghgf
5214g21g5gggg
62n5gng
7g7h69l;f9d2cw1gghdcwg
8f1ZZfZZ
912348548opop
10urrttq89urrtq
11
12
Sheet2
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi Fin Fang Foom

An UDF solution. Use as an excel formula

=ExtractAlpha(A2)

Paste in a module:
Code:
Function ExtractAlpha(rC As Range) As String

With CreateObject("VBSCRIPT.REGEXP")
    .Pattern = "[^a-z]"
    .Global = True
    .IgnoreCase = True
    ExtractAlpha = .Replace(rC.Value, "")
End With
End Function

Hope this helps
PGC
 
Upvote 0
Hi pgc01,


Thank you for repyling. Yes your function does work. But I should've said if we can have a formula solution not a vba solution or any add-ins. Because if I email my co-workers with your add-in they will get a pop up message about a virus and must set your macro secruity. Is it possible to have a formula solution?
 
Upvote 0
Hi again

I may be wrong but I think it's not possible.

The question with problems like yours, that happen frequently, is that excel does not provide any text function to concatenate an array or a range of cells (the equivalent of SUM() for numbers).

In fact you cannot write

=Concatenate(A1:A3) which you would like to be A1 & A2 & A3

This is a basic functionality that precludes a lot of otherwise simple text formulas.

That's why MCONCAT from the MOREFUNC add-ins is so popular.

So, I may be wrong but I think you really need vba or an add-in.

Best regards
PGC
 
Upvote 0
Thanks pgc01 I really do appreciate taking your time on this thread. Then I will probably use a vba solution.


Thank You!
 
Upvote 0
But I should've said if we can have a formula solution not a vba solution or any add-ins.

Hi Fin Fang Foom:

Here is a formula based solution -- however it does use MCONCAT function from MoreFunc Add-in ...
Book1
ABCD
1Extract_Letters
21f2d4g1g56gfdggg
3z1g5gzgg
4\g1h5gf\ghgf
5214g21g5gggg
62n5gng
7g7h69l;f9d2cw1gghlfdcwg
8f1ZZfZZ
912348548opop
10urrttq89urrttq
11
Sheet9


array formula in cell B2 is ...

=MCONCAT(IF(CODE(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1))>64,MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1),""))

this is then copied down.
 
Upvote 0
Still using MOREFUNC..

=REGEX.SUBSTITUTE(A2,"[^a-zA-Z]")

Or..

Define String

Refers to box:=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Sheet2!$A18,1,""),2,""),3,""),4,""),5,""),6,""),7,"")

In C2,

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(String,8,""),9,""),0,""),"\",""),";",""),"/","")
Book1
ABCD
21f2d4g1g56gfdgggfdggg
3z1g5gzggzgg
4\g1h5gfghgfghgf
5214g21g5ggggggg
62n5gngng
7g7h69l;f9d2cw1gghlfdcwgghlfdcwg
8f1ZZfZZfZZ
912348548opopop
10urrttq89urrttqurrttq
Sheet2


HTH
 
Upvote 0
Hi there

If you wanted a quick one-off solution just to remove numbers from column A, you can use this formula in B1.

=SUBSTITUTE(A1,COLUMN(A1)-1,"")

Scroll the formula right to column K, then down. The answer is in colum K

regards
Derek
 
Upvote 0

Forum statistics

Threads
1,225,730
Messages
6,186,698
Members
453,369
Latest member
positivemind

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