[英]Use number of characters in a cell as Excel formula criteria
I have three columns in a spreadsheet, and my goal is to combine the individual references (column B) where the customer is the same (column A) - but only up to a maximum of 20 characters.我在电子表格中有三列,我的目标是合并客户相同的各个参考(B 列)(A 列)——但最多只能包含 20 个字符。
In column E, I use the following formula to combine the references if the value in column A is the same as the cell above: =IF(A2<>A1,"Reference " & B2,E1 & " " & B2)在 E 列中,如果 A 列中的值与上面的单元格相同,我使用以下公式合并引用: =IF(A2<>A1,"Reference " & B2,E1 & " " & B2)
In column G, I use the following formula to only return the final concatenated value: =IF(A2<>A3,CONCATENATE("",E2,""),"")在 G 列中,我使用以下公式仅返回最终的连接值:=IF(A2<>A3,CONCATENATE("",E2,""),"")
However, I'm struggling to find a way to stop combining the references if the cell length contains more than 20 characters, and starting a new concatenation on the next line - like I've put in column I?但是,如果单元格长度包含超过 20 个字符,我正在努力寻找一种方法来停止组合引用,并在下一行开始新的串联 - 就像我在 I 列中放入的那样?
Thanks!谢谢!
It seems you're not looking for a parsimonious spreadsheet.看来您不是在寻找简约的电子表格。 Thus, this is what I can think of:因此,这是我能想到的:
Next to column G, you may add this formula, beginning on row 2 :在 G 列旁边,您可以添加这个公式,从第 2 行开始:
=IF(LEN(G3)>20,IF(LEN(E2)>20,"",E2),IF(G2="","","Reference "&B2))
Column H (or I, as you wish) will have a 3-step IF statement: H 列(或 I,如您所愿)将有一个 3 步 IF 语句:
Thanks to the person who brought the image into the answer.感谢将图像带入答案的人。 I had to refresh it and that made it unavailable again, shamefully.我不得不刷新它,这使它再次不可用,可耻。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.