简体   繁体   English

有没有办法在连接 function 中的项目中添加前导/尾随空格?

[英]Is there a way to add leading/trailing spaces to item in concatenate function?

I am trying to bring together several cells and they have a specific length so if I have我正在尝试将几个单元格组合在一起,它们具有特定的长度,所以如果我有

A1 needs to be 5 chars and the value is 'cat' 
B1 needs to be 6 chars and the value is 'dog' 
Concatenated it would be:
[space space]cat[space space space]dog
or
"  cat   dog"

I'm having trouble finding a function or set of functions that allows this, most want to trim out leading or trailing spaces.我很难找到一个 function 或一组允许这样做的函数,大多数人想要修剪前导或尾随空格。

Yes:是的:

=CONCATENATE(RIGHT(REPT(" ",5)&A1,5),RIGHT(REPT(" ",6)&A2,6))

or as @BigBen stated use & instead of Concatenate:或者正如@BigBen 所说,使用&而不是 Concatenate:

=RIGHT(REPT(" ",5)&A1,5)&RIGHT(REPT(" ",6)&A2,6)

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

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