+ Reply to Thread
Results 1 to 18 of 18

Check for lowercase & uppercase letter next to each other in a string

  1. #1
    Registered User
    Join Date
    05-18-2020
    Location
    Vietnam
    MS-Off Ver
    2010
    Posts
    27

    Check for lowercase & uppercase letter next to each other in a string

    Is there anyway to identify where a lowercase is next to an uppercase in a string?
    For example: CristianoRonaldo
    i want to check for "oR" and separate this string into two words
    Thanks!
    Last edited by TiberSeptim; 05-20-2020 at 03:50 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Check for lowercase & uppercase letter next to each other in a string

    If the name is in A2, put this in B2 to get the first name:

    =LEFT(A2,SMALL(FIND(CHAR(ROW(INDIRECT("65:90"))),A2&"ABCDEFGHIJKLMNOPQRSTUVWXYZ"),2)-1)

    Then put this in C2 to get the last name:

    =RIGHT(A2, LEN(A2)-LEN(B2))


    Copy down ad nauseum.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Check for lowercase & uppercase letter next to each other in a string

    Hi and welcome

    Providing you only have one capital letter other than the first in your string this will separate and add the space . it is an arry formula though so will need to be entered with control + shift + enter. if your surname has two Capitals then it won't work (ie McDonald, O'Rourke and the like)

    Please Login or Register  to view this content.
    Happy with my advice? Click on the * reputation button below

  4. #4
    Registered User
    Join Date
    05-18-2020
    Location
    Vietnam
    MS-Off Ver
    2010
    Posts
    27

    Re: Check for lowercase & uppercase letter next to each other in a string

    If the name is in A2, put this in B2 to get the first name:

    =LEFT(A2,SMALL(FIND(CHAR(ROW(INDIRECT("65:90"))),A2&"ABCDEFGHIJKLMNOPQRSTUVWXYZ"),2)-1)

    Then put this in C2 to get the last name:

    =RIGHT(A2, LEN(A2)-LEN(B2))


    Copy down ad nauseum.
    thanks for the answers!
    However, it seems not to work on strings like this "Hanh Khuc Ngay Va DemPhan Huynh Dieu", only get "Hanh", not "Hanh Khuc Ngay Va Dem"
    Please help
    Thanks!
    Last edited by TiberSeptim; 05-19-2020 at 12:21 AM.

  5. #5
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Check for lowercase & uppercase letter next to each other in a string

    Not sure how good you are with Macros and VBA. This will put a space infront of each Capital letter in column A

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-18-2020
    Location
    Vietnam
    MS-Off Ver
    2010
    Posts
    27

    Re: Check for lowercase & uppercase letter next to each other in a string

    Quote Originally Posted by Crooza View Post
    Not sure how good you are with Macros and VBA. This will put a space infront of each Capital letter in column A
    Thanks, i was able to put a space in front of each Capital letter using your code. But then can i separate the string into two parts, like "Hanh Khuc Ngay Va DemPhan Huynh Dieu" ==> "Hanh Khuc Ngay Va Dem" and "Phan Huynh Dieu"

  7. #7
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Check for lowercase & uppercase letter next to each other in a string

    You could separate them but we’d need to know the rule or logic to be used to know which parts go where.

  8. #8
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,425

    Re: Check for lowercase & uppercase letter next to each other in a string

    This macro looks for your existing data in Column A starting at Row 1 and outputs the split text starting in Column B. Also, this code will handle as many lower/upper case combinations as there are in the cells (it is not limited to just one such combination of characters).
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-18-2020
    Location
    Vietnam
    MS-Off Ver
    2010
    Posts
    27

    Re: Check for lowercase & uppercase letter next to each other in a string

    Thank you very much!

  10. #10
    Registered User
    Join Date
    05-18-2020
    Location
    Vietnam
    MS-Off Ver
    2010
    Posts
    27

    Re: Check for lowercase & uppercase letter next to each other in a string

    Quote Originally Posted by Rick Rothstein View Post
    This macro looks for your existing data in Column A starting at Row 1 and outputs the split text starting in Column B. Also, this code will handle as many lower/upper case combinations as there are in the cells (it is not limited to just one such combination of characters).
    Can you add number/uppercase combinations to this code?
    Thanks!

  11. #11
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,425

    Re: Check for lowercase & uppercase letter next to each other in a string

    Try this...
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    05-18-2020
    Location
    Vietnam
    MS-Off Ver
    2010
    Posts
    27

    Re: Check for lowercase & uppercase letter next to each other in a string

    Thank you!

  13. #13
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,504

    Re: Check for lowercase & uppercase letter next to each other in a string

    You must be musical fan
    Try:
    Please Login or Register  to view this content.
    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Quang PT

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Check for lowercase & uppercase letter next to each other in a string

    Hi,

    =LEFT(A1,MATCH(2,MMULT(N(ABS({109.5,77.5}-CODE(MID(MID(A1,ROW(INDIRECT("1:"&LEN(A1)-1)),2),{1,2},1)))<13),{1;1}),0))

    No need for CSE with that one.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  15. #15
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,504

    Re: Check for lowercase & uppercase letter next to each other in a string

    Quote Originally Posted by XOR LX View Post
    Hi,

    =LEFT(A1,MATCH(2,MMULT(N(ABS({109.5,77.5}-CODE(MID(MID(A1,ROW(INDIRECT("1:"&LEN(A1)-1)),2),{1,2},1)))<13),{1;1}),0))

    No need for CSE with that one.

    Regards
    "Hanh Khuc Ngay Va DemPhan Huynh Dieu" becomes "Hanh Khuc Ngay Va Dem"
    You missed 2nd part.
    More info:
    "Hanh Khuc Ngay Va Dem" is name of a Vietnamese famous song, and "Phan Huynh Dieu" is author, and the OP wishes to keep them separately.

  16. #16
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Check for lowercase & uppercase letter next to each other in a string

    Quote Originally Posted by bebo021999 View Post
    "Hanh Khuc Ngay Va DemPhan Huynh Dieu" becomes "Hanh Khuc Ngay Va Dem"
    You missed 2nd part.
    More info:
    "Hanh Khuc Ngay Va Dem" is name of a Vietnamese famous song, and "Phan Huynh Dieu" is author, and the OP wishes to keep them separately.
    I didn't miss the second part. The required formula for that part is evidently straightforward and has already been given, e.g. by JBeaucaire.

    Quote Originally Posted by JBeaucaire View Post
    Then put this in C2 to get the last name:

    =RIGHT(A2, LEN(A2)-LEN(B2))
    An alternative would be:

    =SUBSTITUTE(A2,B2,"")

    Regards
    Last edited by XOR LX; 05-20-2020 at 02:34 AM.

  17. #17
    Registered User
    Join Date
    05-18-2020
    Location
    Vietnam
    MS-Off Ver
    2010
    Posts
    27

    Re: Check for lowercase & uppercase letter next to each other in a string

    Quote Originally Posted by bebo021999 View Post
    You must be musical fan
    Thanks all for the answers!
    Yeah i'm doing some works about music and authors

  18. #18
    Registered User
    Join Date
    06-21-2023
    Location
    Midwest US
    MS-Off Ver
    19
    Posts
    1

    Re: Check for lowercase & uppercase letter next to each other in a string

    You are amazing bebo!

+ 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. Uppercase to Lowercase
    By Mattsmash in forum Excel General
    Replies: 4
    Last Post: 11-04-2019, 06:43 PM
  2. Find the last lowercase letter in a string
    By Nachtschade in forum Excel General
    Replies: 3
    Last Post: 03-19-2019, 01:41 PM
  3. Replies: 25
    Last Post: 04-21-2015, 10:19 AM
  4. Replies: 7
    Last Post: 06-05-2014, 02:50 AM
  5. [SOLVED] Finding an uppercase letter in a string parameter of a UDF
    By dredwolf in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2012, 11:43 PM
  6. Check to see if a string is all in uppercase?
    By pablowilks in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-12-2012, 05:52 AM
  7. [SOLVED] uppercase to lowercase
    By Missy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-03-2005, 06:06 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