+ Reply to Thread
Results 1 to 12 of 12

Macro to split a string into 2 texts based on where is the capital letter

  1. #1
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Macro to split a string into 2 texts based on where is the capital letter

    Hi guys,

    I have an odd export and i have normal names and combined names. When i say normal I say e.g Ionut etc.
    The odd format comes from the export and it seems that some names have the format like JohnMonet.

    I would like to ask for help from you guys, in order to run a macro that will split these formats into John and Monet. I can insert a new column --E and in that E i want to have the Monet and the rest to stay in col. D.

    The macro should run only when it will see that inside of a word is another capital letter and will take the rest of the word starting from the capital letter to the rest of the word and will paste it in D.

    Thank you,
    Ionut
    Please consider:
    Be polite. Thank those who have helped you.
    Click the star icon in the lower left part of the contributor's post and add Reputation. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Posting code between tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macro to split a string into 2 texts based on where is the capital letter

    Can you give some more examples please? I sort of understand but "inside of a word is another capital letter and will take the rest of the word starting from the capital letter to the rest of the word" has thrown me a bit, are you saying that "sauSages" would be split as sau & Sages?
    If someone has helped you then please add to their Reputation

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: Macro to split a string into 2 texts based on where is the capital letter

    By formula maybe??
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Macro to split a string into 2 texts based on where is the capital letter

    Here you go pjwhitfield
    Attached Files Attached Files
    Last edited by IonutC; 09-13-2016 at 04:26 AM.

  5. #5
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Macro to split a string into 2 texts based on where is the capital letter

    Thank you Glen. This is what I need, however I want it in a macro because i want it to test if there is a capital letter in the word or not. Because I have in col. D and correct names and if i drag and drop the formula into correct cells the result is different.

    Thank you for your reply!

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Macro to split a string into 2 texts based on where is the capital letter

    Try
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Macro to split a string into 2 texts based on where is the capital letter

    Thank you Jindon!

    I have an error "Run time error 5" Invalid procedure or call or argument.

    I have to install something as Reference in the Library?

  8. #8
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Macro to split a string into 2 texts based on where is the capital letter

    the highlighted line is ==> a(i, 2) = .Execute(a(i, 1))(0)

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Macro to split a string into 2 texts based on where is the capital letter

    No error.....................
    Attached Files Attached Files

  10. #10
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Macro to split a string into 2 texts based on where is the capital letter

    Yeah Thank you Jindon! It is what I needed. The error comes from a name BRETT which has all the letters as capital letters.

    However I made them correct and it worked. Is there a way to put this code to see if all the letters are capital letters to skip the process of splitting?

    Thank you for your help!

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Macro to split a string into 2 texts based on where is the capital letter

    Then try change to
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor IonutC's Avatar
    Join Date
    01-28-2016
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2019
    Posts
    486

    Re: Macro to split a string into 2 texts based on where is the capital letter

    Jindon you rock!

    Thank you very much for your help!

+ 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. How do I split a word based on the capital letters
    By benji007007 in forum Excel General
    Replies: 4
    Last Post: 04-20-2015, 10:40 PM
  2. lower case letter to capital letter
    By kuzna26 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-10-2014, 03:49 AM
  3. Split cells based on Capital Letters
    By AntyLani in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-17-2013, 11:24 AM
  4. [SOLVED] Macro to make the first letter of every word capital
    By nenadmail in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-31-2012, 04:06 PM
  5. Replies: 7
    Last Post: 02-19-2007, 12:17 AM
  6. Replies: 5
    Last Post: 07-13-2006, 12:15 AM

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