VBA or formula to give lower case words from string

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,602
Office Version
  1. 365
Platform
  1. Windows
Hey all

Through column B I have a list of strings with a mix of lower and upper case words, example

BIG RIPE apple
small yellow BANANA
green FRUIT WITH PIPS

I'd like a formula or vba that will only display the lower case words from the given string, d=so from above examples the results would be...


apple
small
green

TIA
 
Assuming you are correct and that mixed letter case words should also be removed along with all upper case words, give this a try...
VBA Code:
Function LCtext(ByVal S As String) As String
  Dim X As Long, Arr() As String
  Arr = Split(S)
  For X = 0 To UBound(Arr)
    If Arr(X) Like "*[!a-z]*" Then Arr(X) = ""
  Next
  LCtext = Application.Trim(Join(Arr))
End Function
Actually, I can compact this macro even more...
VBA Code:
Function LCtext(ByVal S As String) As String
  Dim V As Variant
  For Each V In Split(S)
    If Not V Like "*[!a-z]*" Then LCtext = Trim(LCtext & " " & V)
  Next
End Function
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
If you can hear I'm clapping hands both of you.
I was supposed that is something possible to be done with regEx, but code do not exclude numbers.
Mr. Rothstein's code is maestral use of the split and join functions.
This is so simple and beautiful.
In the name of the Redspana who is not interested about his question any more...
Thank you.
 
Upvote 0
but code do not exclude numbers.
There is no requirement in the OP's post to exclude numbers. And who is to say whether a number is upper case or lower case? ;)

In the name of the Redspana who is not interested about his question any more...
That is a bit harsh. There is no requirement for OP's to respond instantly, or in fact at all.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,485
Members
448,967
Latest member
visheshkotha

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