Excel / Formula限制,包含255个字符和if语句

时间:2017-04-20 16:12:30

标签: excel excel-vba excel-formula vba

早上好, 我想检查单元格,看看它们是否属于下面的excel公式的A,B或C类别,

=IF(CB3=0,"",
(IF(N3="
215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 324, 325, 326, 327, 328, 329, 330, 331, 336, ","A",

IF(N3="215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, "B",

IF(N3="301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 324, 325, 326, 327, 328, 329, 330, 331, 336, ","C",
IF(LEN(N3)=0,"",LEFT(N3,(LEN(N3)-2))))))))

我已经看到255个文本限制错误,以便我无法处理它,excel说我可以使用CONCATENATE或&,但不知道我能用这个做什么。有什么建议?非常感谢!

1 个答案:

答案 0 :(得分:2)

它正在抱怨你要测试的这个非常长的文本字符串:

CONCATENATE("215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 246, 247, 248, 249, 250, 251,", " 252, 253, 254, 255, 256, 257, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 324, 325, 326, 327, 328, 329, 330, 331, 336, ")

相反,使用连接来分解它:

="This is a very long string, isn't it"

这两个在功能上是等价的,因为连接只是将两个字符串组合成一个长字符串。

所以...我们在这里所做的就是分解你的长字符串,如:

=Concatenate("This is a very long ", "string, isn't it")

分成两个较小的字符串并将它们连接在一起:

This is a very long string, isn't it

这两个公式在功能上是等价的,因为结果值将是

{{1}}