简体   繁体   English

如何制作一个 excel (365) function 识别同一单元格中的不同单词并单独更改它们

[英]How to make an excel (365) function that recognizes different words in the same cell and changes them individually

What im working with我在做什么

I have a list of product names, but unfortunately they are written in uppercase I now want to make only the first letter uppercase and the rest lowercase but I also want all words with 3 or less symbols to stay uppercase我有一个产品名称列表,但不幸的是它们是用大写字母写的我现在只想让第一个字母大写和 rest 小写但我也希望所有带有 3 个或更少符号的单词保持大写

im trying if functions but nothing is really working我正在尝试功能,但没有任何效果

i use the german excel version but i would be happy if someone has any idea on how to do it im trying different functions for hours but nothing is working我使用德语 excel 版本,但如果有人知道如何做我会很高兴我尝试了几个小时不同的功能但没有任何效果

=IF(LENGTH(C6)<=3,UPPER(C6),UPPER(LEFT(C6,1))&LOWER(RIGHT(C6,LENGTH(C6)-1)))

but its a #NAME error excel does not recognize the first and the last bracket但它的#NAME 错误 excel 无法识别第一个和最后一个括号

This is hard: Let me explain:这很难:让我解释一下:

  1. I do believe there are German words in the mix that are below 4 characters in length that you should exclude.我确实相信混合中的德语单词长度低于 4 个字符,您应该排除这些单词。 My German isn't great but there would probably be a huge deal of words below 4 characters;我的德语不是很好,但可能会有很多 4 个字符以下的单词;
  2. There seems to be substrings that are 3+ characters in length but should probably stay uppercase, eg '550E/ER';似乎有些子字符串的长度超过 3 个字符,但应该保持大写,例如“550E/ER”;
  3. There seem to be quite a bunch of characters that could be used as delimiters to split the input into 'words'.似乎有很多字符可以用作分隔符将输入拆分为“单词”。 It's hard to catch any of them without a full list;如果没有完整的列表,很难找到其中的任何一个;
  4. Possible other reasons;可能的其他原因;

With the above in mind I think it's safe to say that we can try to accomplish something that you want as best as we can.考虑到上述情况,我认为可以肯定地说,我们可以尽我们所能尝试完成您想要的事情。 Therefor I'd suggest因此我建议

  • To split on multiple characters;拆分多个字符;
  • Exclude certain words from being uppercase when length < 3;当长度 < 3 时,排除某些单词为大写;
  • Include certain words to be uppercase when length > 3 and digits are present;当长度 > 3 且存在数字时,将某些单词包含为大写;
  • Assume 1st character could be made uppercase in any input;假设第一个字符在任何输入中都可以变成大写;

For example:例如:

在此处输入图像描述

Formula in B1 : B1中的公式:

=MAP(A1:A5,LAMBDA(v,LET(x,TEXTSPLIT(v,{"-","/"," ","."},,1),y,TEXTSPLIT(v,x,,1),z,TEXTJOIN(y,,MAP(x,LAMBDA(w,IF(SUM(--(w={"zu","ein","für","aus"})),LOWER(w),IF((LEN(w)<4)+SUM(IFERROR(FIND(SEQUENCE(10,,0),w),)),UPPER(w),LOWER(w)))))),UPPER(LEFT(z))&MID(z,2,LEN(v)))))

You can see how difficult it is to capture each and every possibility;你可以看到捕捉每一种可能性是多么困难;

  • The minute you exclude a few words, another will pop-up (the 'x' between numbers for example. Which should stay upper/lower-case depending on the context it is found in);在您排除几个词的那一刻,另一个会弹出(例如,数字之间的“x”。它应该保持大写/小写,具体取决于它所在的上下文);
  • The second you include words containing digits, you notice that some should be excluded ('00SICHERUNGS....');第二个你包括包含数字的单词,你注意到一些应该被排除在外('00SICHERUNGS ....');
  • If the 1st character would be a digit, the whole above solution would not change 1st alpha-char in upper;如果第一个字符是数字,则上述整个解决方案都不会更改上部的第一个字母字符;
  • Maybe some characters shouldn't be used as delimiters based on context?也许某些字符不应该用作基于上下文的分隔符? Think about hypenated words;想想连字符;
  • Possible other reasons.可能的其他原因。

Point is, this is not just hard, it's extremely hard if not impossible to do on the type of data you are currently working with, Even if one is proficient with writing a regular expression (chuck in all (non-available to Excel) tokens, quantifiers and methods if you like).重点是,这不仅困难,而且即使不是不可能,也很难对您当前使用的数据类型进行操作,即使一个人精通编写正则表达式(查入所有(不可用于 Excel)标记,量词和方法,如果你喜欢的话)。 I'd doubt all edge-case could be covered.我怀疑是否可以涵盖所有边缘情况。

Because you are dealing with any number of words in a cell you'll need to get crafty with this one.因为您要处理一个单元格中的任意数量的单词,所以您需要巧妙地处理这个单词。 Thankfully there is TEXTSPLIT() and TEXTJOIN() that can make short work of splitting the text into words, where we can then test the length, change the capitalization, and then join them back together all in one formula:值得庆幸的是,有TEXTSPLIT()TEXTJOIN()可以简化将文本拆分为单词的工作,然后我们可以在其中测试长度,更改大小写,然后将它们重新组合到一个公式中:

 =TEXTJOIN(" ", TRUE, IF(LEN(TEXTSPLIT(C6," "))<=3,UPPER(TEXTSPLIT(C6," ")),PROPER(TEXTSPLIT(C6," "))))

Also used PROPER() formula as well, which only capitalizes the first character of a word.还使用了PROPER()公式,它只将单词的第一个字符大写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM