简体   繁体   English

如何通过加零将文本数据格式化为6个字符?

[英]How to format text data to have 6 characters by adding zeros?

I need to format text in cells (excel) that has 2-3 characters (both letters and numbers) to a new cell but the data to have be 6 characters long. 我需要将具有2-3个字符(字母和数字)的单元格(excel)中的文本格式化为新单元格,但数据长度必须为6个字符。 I want to add zeros infront of the data. 我想在数据前添加零。 ex. 恩。 im45 -> 00im45 456->000456 4d4e-> 004d4e id->0000id im45-> 00im45 456-> 000456 4d4e-> 004d4e id-> 0000id

lets assume your data starts in B2. 假设您的数据从B2开始。 Add six 0 to the front of the value of the cell as text and then take the right most 6 characters. 在单元格值的前面添加六个0作为文本,然后采用最右边的6个字符。 This can be done using hte following formula: 可以使用以下公式完成此操作:

=RIGHT("000000"&B2,6)

If you needed more than 6 characters you might want to look into the REPT function. 如果您需要超过6个字符,则可能需要查看REPT函数。

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

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