Split Uppercase words in Excel

前端 未结 6 1501
花落未央
花落未央 2020-12-15 19:48

I would like to split all words in my cell by Uppercase, an example:

Original values:

MikeJones
RinaJonesJunior
MichealSamuelsLurth

6条回答
  •  被撕碎了的回忆
    2020-12-15 20:05

    Here's a worksheet function solution. It ain't pretty, but if you're totally averse to using VBA, then I think you're stuck with ugly options only. For text in A1, paste the following into B1 and press Ctrl+Shift+Enter to enter the formula as an array formula:

    =IFERROR(INDEX(IF(CODE(MID(D1,ROW(INDIRECT("A2:A"&LEN(D1))),1))<=90,IF(CODE(MID(D1,ROW(INDIRECT("A2:A"&LEN(D1))),1))>=65,IF(MID(D1,ROW(INDIRECT("A1:A"&LEN(D1)-1)),1)<>" ",REPLACE(D1,ROW(INDIRECT("A2:A"&LEN(D1))),1," "&MID(D1,ROW(INDIRECT("A2:A"&LEN(D1))),1)),D1),D1),D1),MIN(IF(CODE(MID(D1,ROW(INDIRECT("A2:A"&LEN(D1))),1))<=90,IF(CODE(MID(D1,ROW(INDIRECT("A2:A"&LEN(D1))),1))>=65,IF(MID(D1,ROW(INDIRECT("A1:A"&LEN(D1)-1)),1)<>" ",ROW(INDIRECT("A1:A"&LEN(D1)-1)),2000000),2000000),2000000))),D1)
    

    I told you it was ugly!

    And for all that effort, that will only split the first and second name. For more splits, fill the formula over to the right. So for example, if you have a list of names in A1:A10, and you think the most words in any name is four, you could enter the formula in B1 (as an array formula!), fill down to B10, then fill right to E10. Your list of split names will be in E1:E10.

    sample use of formula

    If you're inclined to jump down the rabbit hole, here's a brief explanation of what the formula does:

    1. Check each character to see if it is in the ASCII range for capital letters and not preceded by a space. The first character of the name is skipped.
    2. An array equal in size to the length of the string (minus 1) is populated as follows: If a match is found, the string is stored with the matching character replaced by a space preceding itself. If no match is found, the original string is stored.
    3. The first element from this array that corresponds to a match is returned. If no match is found, the original string is returned.

提交回复
热议问题