+ Reply to Thread
Results 1 to 4 of 4

Find the first two Uppercase letters in a string and return that value

  1. #1
    Registered User
    Join Date
    03-13-2016
    Location
    Appleton, Wisconsin
    MS-Off Ver
    Microsoft 2013
    Posts
    2

    Find the first two Uppercase letters in a string and return that value

    Hi everyone, this is my first post here!

    I have an issue where I have a column with a state, city, some special characters, and maybe the spelled out version of the state all in one cell.

    Examples:

    Kansas City KS
    Denver CO company name
    Salt Lake City UT companyname
    Southern Cal
    Fairfield OH RET/SUPP CHN
    St. Louis MO

    My goal is to identify if there is anything named as a state, or a state abbreviation, (as close as I can get it).

    I have a full spreadsheet of state names and state abbreviations to help me with the lookup, but I cannot figure out how use the "Find" function with a "Lookup" function to return me anything close to what I need.

    It would be useful to figure out to find the two uppercase letters in the string, but I have googled and googled and cannot figure it out.

    Any suggestions would be greatly appreciated.

    Thank you!

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Find the first two Uppercase letters in a string and return that value

    Enter formula in B1 and copy down

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    v A B
    1 Kansas City KS KS
    2 Denver CO company name CO
    3 Salt Lake City UT companyname UT
    4 Southern Cal
    5 Fairfield OH RET/SUPP CHN OH
    6 St. Louis MO MO
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Registered User
    Join Date
    03-13-2016
    Location
    Appleton, Wisconsin
    MS-Off Ver
    Microsoft 2013
    Posts
    2

    Re: Find the first two Uppercase letters in a string and return that value

    Thank you so much! I appreciate the quick response... this will certainly help me now and going forward with other problems.

  4. #4
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Find the first two Uppercase letters in a string and return that value

    Quote Originally Posted by CrazyPerson View Post
    It would be useful to figure out to find the two uppercase letters in the string
    with AlKey formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    but it's not solution for : Kansas City ab KS

    ==
    With UDF VBA regex (for now and future):

    Step 1: Add VBA reference to "Microsoft VBScript Regular Expressions 5.5" (IMPORTANT!)
    • Select "Developer" tab
    • Select "Visual Basic" icon from 'Code' ribbon section
    • In "Microsoft Visual Basic for Applications" window select "Tools" from the top menu.
    • Select "References"
    • Check the box next to "Microsoft VBScript Regular Expressions 5.5" to include in your workbook.
    • Click "OK"
    Step 2: Click on Insert Module. If you give your module a different name make sure the Module does not have the same name as the UDF below.
    Step 3: In the big text window in the middle insert the following:
    Please Login or Register  to view this content.
    Step 4: Save and close the Microsoft Visual Basic for Applications Editor window.
    usage: =regex(A1,"your pattern")

    in this case:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    with this code you can define much more patterns not only as simply as ([A-Z][^a-z]{2})|([A-Z]{2})$")
    Last edited by sandy666; 03-13-2016 at 09:21 PM. Reason: RegEx solution added

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 03-30-2015, 03:20 PM
  2. [SOLVED] VBA Code for Uppercase or Lowercase letters
    By gbloemke in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-26-2014, 10:37 AM
  3. Changing Uppercase letters to lowercase
    By tubells in forum Excel General
    Replies: 4
    Last Post: 03-17-2010, 02:12 PM
  4. VB - Making first letters of words uppercase
    By Smurlos in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2010, 08:10 PM
  5. Find Specific Trailing Letters and Return Message
    By Cleman04 in forum Excel General
    Replies: 1
    Last Post: 03-20-2009, 12:06 PM
  6. Replies: 2
    Last Post: 10-02-2005, 08:05 PM
  7. [SOLVED] CHANGE WHOLE EXCEL worksheet TO UPPERCASE LETTERS?
    By mineralgirl in forum Excel General
    Replies: 4
    Last Post: 09-02-2005, 09:05 PM

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