+ Reply to Thread
Results 1 to 14 of 14

Excel 2008 : Formula to remove consecutive capital letters from text strings

  1. #1
    Registered User
    Join Date
    07-02-2012
    Location
    United States
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    6

    Question Formula to remove consecutive capital letters from text strings

    I need an Excel genius!!

    I have a bunch of text strings in an Excel file (2008 for Mac) that look like this:

    Milwaukee
    New York
    San Diego 1234
    XYZXYZ San Juan
    Adelaide XY Australia
    Boston ABC123
    AlbanyXYZ

    And I want it to look like this:

    Milwaukee
    New York
    San Diego
    San Juan
    Adelaide Australia
    Boston
    Albany

    That is, I want to remove 3 things:
    1. Numbers
    2. Extra leading/trailing spaces
    3. Capitalized letters that are immediately next to other capitalized letters

    I took care of 1 and 2 with =TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"1",""),"2",""),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9",""),"0","")), but how do I take of 3?

    How can I remove only those capitalized letters that are right next to other capitalized letters?

    Thanks for your help!!

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Formula to remove consecutive capital letters from text strings

    Hi JesseG123 and welcome to the forum,

    Does the Mac Excel have the Proper Function? This would do what you want.
    http://spreadsheets.about.com/od/exc...124_proper.htm
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    07-02-2012
    Location
    United States
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    6

    Re: Formula to remove consecutive capital letters from text strings

    Wow, that was a quick response.

    The version for Mac does have the Proper function, but how can I use this to delete characters? I don't just need to turn some uppercase letters into lowercase letters. I need to remove only those characters that are uppercase letters which are immediately adjacent to another uppercase letter.

    E.g., I want to go from "New Jersey NJXYZ" to "New Jersey". Proper on Mac would just output "New Jersey Njxyz".

    Thanks!!
    Last edited by JesseG123; 07-02-2012 at 09:11 PM. Reason: Clarify

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Formula to remove consecutive capital letters from text strings

    Hi JesseG123,

    Find your answer in the attached. It took a few helper columns to accomplish this.
    I broke up your words by spaces and then checked for a vowel in each word. If no vowel was there I tossed out and reassembled the words again. See the attached and look at the formulas and see if it works for you.

    BTW - I only did a 5 possible word string in Col A.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-02-2012
    Location
    United States
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    6

    Thumbs up Re: Formula to remove consecutive capital letters from text strings

    That's great, thanks so much! The initial text needs to be trimmed for it to work perfectly, but that's really amazing... this is a big lifesaver.

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formula to remove consecutive capital letters from text strings

    Without having looked at the sample file, wouldn't the logic being used remove, for example, "St" - as in "St Louis"?

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Formula to remove consecutive capital letters from text strings

    @Cutter,

    The job was impossible for all possible words. I only left words that had vowels in them. You are correct that St Louis would drop the St.
    Logic is a funny thing. It works for some problems and not others. Euclidian Geometry works on earth as long as it isn't too much earth. This problem needed spaces between words and a vowel in each name to survive my code.

    I just guessed/assumed that the OP had city names that all had vowels in them.

    There would be other problems if there weren't spaces between the separate words. In the example "AlbanyXYZ" wouldn't be converted correctly as there is no space. I assumed s/he typed it incorrectly and there really was a space between the y and X.

  8. #8
    Registered User
    Join Date
    07-02-2012
    Location
    United States
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    6

    Re: Formula to remove consecutive capital letters from text strings

    The initial formula is a really good start (and very smart), but it turns out there are actually 3 issues:

    1. As Cutter notes, in examples like "St Louis", the "St" is removed (and I need it not to be removed).

    2. As MarvinP notes, examples like "AlbanyXYZ" are problematic because they don't get separated into two words.

    3. I'm supposed to use this to eliminate consecutive uppercase letters in text strings that also contain characters from other languages (e.g. Chinese, Russian, Arabic, etc.). The characters that need to be removed will always be English.

    So I really need to pick out only and all of those characters that are
    (A) English,
    (B) uppercase, and
    (C) right next to at least one other uppercase English character.

    Any ideas?

    Thanks so much!
    Last edited by JesseG123; 07-03-2012 at 10:15 AM. Reason: More issues than I thought

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Formula to remove consecutive capital letters from text strings

    Hey JesseG123,

    You have Mac 2008 Excel which doesn't have VBA included. Excel doesn't know the difference between capital and lower case letters without going to VBA.

    To include the "St" you could add an "IFERROR(FIND("St",B2),FALSE) in the formula in G2.
    You should also include "y" as a vowel for cities like Lynn and "Ft" for the abreviation of "Fort".

    I have no answer for the AlbanyXYZ if there isn't a space in there.
    Last edited by MarvinP; 07-03-2012 at 10:21 AM.

  10. #10
    Registered User
    Join Date
    07-02-2012
    Location
    United States
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    6

    Re: Formula to remove consecutive capital letters from text strings

    That helps, thanks -- the more possibilities taken care of, the better. I now have access to the version of Excel from Microsoft Office Home and Student 2010 on a PC. Is there a better way to solve these problems with the better version of Excel?

    Y'all are the best!

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Formula to remove consecutive capital letters from text strings

    Hi JesseG,

    If you had VBA behind Excel we might write a VBA Macro that did what you needed. I'd say you would need more than 5000 rows that needed "fixing" before the time would be worth it.

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Formula to remove consecutive capital letters from text strings

    With VBA a simple UDF should work:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  13. #13
    Registered User
    Join Date
    07-02-2012
    Location
    United States
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    6

    Talking Re: Formula to remove consecutive capital letters from text strings

    Thanks for your help!! I really appreciate it.
    Not to push my luck... but if either of you have any bright ideas about how to make this work across languages with different characters (e.g. Chinese, Arabic, Greek, etc.), let me know!
    You guys rock!

    PS. Re: MarvinP, definitely worth it -- I need to fill out about 40,000 rows for at least 29 different languages, for a total of something like 1,160,000 rows total.
    Last edited by JesseG123; 07-08-2012 at 11:20 PM.

  14. #14
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Formula to remove consecutive capital letters from text strings

    Perhaps it's time to upgrade to Excel 2011 for the Mac. It has VBA abilities.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1