To allow numbers, just add the 0-9 that I show in red below...
Code:
Function UpperCaseWords(S As String) As String
Dim X As Long, TempText As String
TempText = " " & S & " "
For X = 2 To Len(TempText) - 1
If Mid(TempText, X, 1) Like "[!A-Z[B][COLOR="#FF0000"]0-9[/COLOR][/B] ]" Or Mid(TempText, X - 1, 3) Like "[!A-Z][A-Z][!A-Z]" Then
Mid(TempText, X) = " "
End If
Next
UpperCaseWords = Application.Trim(TempText)
End Function
|
Hi Rick,
I know this post was from a long time ago, but this VBA code is very similar to what I need for my problem.
In a cell, I have a list of genes (capital letters, sometimes also containing numbers in random locations) with their descriptions after them. I need to extract only the full gene names, separated by something (like a space) so I can parse them into individual cells with other excel functions. For example, I have the following:
[CACNG2 - calcium channel, voltage-dependent, gamma subunit 2, STXBP5L - syntaxin binding protein 5-like, SLC8A3 - solute carrier family 8 (sodium/calcium exchanger), member 3, RIMS1 - regulating synaptic membrane exocytosis 1, AKAP12 - a kinase (prka) anchor protein 12
after extraction should look like:
CACNG2 STXBP5L SLC8A3 RIMS1 AKAP12
the current VBA code (incorrectly) yields:
CACNG2 2 STXBP5 5 SLC8 3 8 3 RIMS1 1 AKAP12
Is there anyway to modify the code to extract these gene names?
Thank you so much for any help you can give.