问题
Is it possible to pad a cell with spaces to ensure that it is the correct length?
Here's an example with *
representing spaces.
Input Output
----- ------
red red**
blue blue*
The words are padded with spaces to ensure the cell content is 5 characters long.
回答1:
Try this:
=LEFT(A1&"*****",5)
We are adding lots of stars(*) then just cutting from left
5 characters.
回答2:
As per suggested comment:
=LEFT(A1 & REPT("*",5),5)
original:
=A1 & REPT("*",5-len(A1))
main advantage being that you can pass the length and the pad character as a cell reference, and easily update
回答3:
I had to right pad the numbers in a cell with 0 to make it maximum 9 characters. All had uneven numbers in the cell. I used the below formula to achieve the result. For me the least characters present in the cell was 3. =LEFT(G41 & REPT("0",6),9)
来源:https://stackoverflow.com/questions/29363823/padding-a-word-with-spaces-to-fill-a-cell