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.
Right-click on one of the selected cells and choose "Format Cells" from the context menu. In the "Format Cells" dialog box, click on the tab for "Alignment." In the "Cell Margins" section, enter the amount of space that you want around the cells. You can enter different values for top, bottom, left, and right.
Pad for display onlyThe TEXT function can apply number formats of any kind, including currency, date, percentage, etc. By applying a number format like "00", "000", "0000", you can "pad" numbers with as many zeros as you like. Zeros will only be added where needed...
Try this:
=LEFT(A1&"*****",5)
We are adding lots of stars(*) then just cutting from left
5 characters.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With