Consulting

Results 1 to 6 of 6

Thread: Solved: Extracting words in Uppercase

  1. #1

    Question Solved: Extracting words in Uppercase

    Hello guys,

    is there any way by which we can extract only the upper case words from a sentence?

    For E.g :- 1. AMA - Cincinnati
    2. AMA - Minnesota
    3. SHRM New Jersey Metro EMA Chapter
    4. FPRA Central West Coast Chapter
    5. NCMA-LA South Bay Chapter


    .... I want to extract all the words in Upper case in a seperate cell.


    Thanks,
    Manoj

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Hi Manoj,

    You could add a UDF to your workbook, coded as:
    Function UpperWords(str As Variant) As String
    Dim i As Integer, sTemp As String, StrTmp As String
    For i = 0 To UBound(Split(str, " "))
      StrTmp = Split(str, " ")(i)
      If UCase(StrTmp) = StrTmp Then sTemp = sTemp & " " & StrTmp
    Next i
    UpperWords = Trim(sTemp)
    End Function
    You could then call this UDF like any other formula. For example:
    =UPPERWORDS(A1)
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Thanks Macropod...

    This is what I wanted... Thanks a lot...


    Regards,
    Manoj

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You could also try this array formula

    =MID(A2,4,MATCH(1,(CODE(MID(A2,ROW(INDIRECT("4:"&LEN(A2))),1))<65)*1,0)-1)
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Hi xld,

    In my testing, your formula returns only the first upper-case word.

    A potential flaw in my code is that it returns numbers also, but that doesn't seem to bother the OP.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  6. #6
    Yup.. I too tested it and it is returning only the first upper-case word.


    Regards,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •