Formula to extract upper case words in a text string

spbcson

New Member
Joined
Feb 11, 2013
Messages
15
IS THERE A FORMULA TO EXTRACT A UPPER CASE FROM A TEXT STRING IN A CELL? Example in cell A1 i have this text string:
//-- y MICROSOFT EXCEL computer software June 23489​

How can I get only the words "MICROSOFT EXCEL"
 
Hi Peter

Is the last bit "(?= |$)" not redundant?

With "[^ ]*" you capture any number of non-space characters.
This means that what follows must be either a space or the end of line.
The "(?= |$)" seems not to add any information...

... or I'm missing something which is quite possibly the case, haven't been here for a while :)
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
haven't been here for a while
Hello Pedro. Good to see you - you have been missed!! :)
Especially whenever I attempt a RegExp question as I always remember that it was you that got me interested in the topic and explained a lot to me in my early days in the subject. :)

Is the last bit "(?= |$)" not redundant?
I think you might be right .... which makes @JEC almost right. ?

I think the look-ahead was left over from when I was trying to get rid of all the unwanted text with only a regexp replace. That is, without the Application.Trim, but I got stuck.
Not that it makes much difference, but looking again now, I think with the look-ahead I could at least get back to a vba trim?

VBA Code:
Function UCtext(s As String) As String
  With CreateObject("VBScript.RegExp")
    .Global = True
'    .Pattern = "[^ ]*[^A-Z\.& \-][^ ]*(?= |$)"
    .Pattern = "(^| )[^ ]*[^A-Z\.& \-][^ ]*(?= |$)"
'    UCtext = Application.Trim(.Replace(s, ""))
    UCtext = LTrim(.Replace(s, ""))
  End With
 
Upvote 0

Forum statistics

Threads
1,215,223
Messages
6,123,722
Members
449,116
Latest member
Aaagu

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