简体   繁体   中英

Split cell with specific formatting

I am trying to find and split an input in cell A2, and it needs to output in a specific format up to 3 digits after the second period and not outputting anything after if it finds a 3rd period.

I'm currently using:

=IF(A2="","",TEXT(LEFT(A2,SEARCH(".",A2,1)-1),"00000")&"."&TEXT(MID(A2,SEARCH(".",A2)+1,SEARCH(".",A2,SEARCH(".",A2)+1)-SEARCH(".",A2)-1),"000000")&"."&TEXT(RIGHT(A2,LEN(A2)-SEARCH(".",A2,SEARCH(".",A2)+1)),"000"))

however this pulls ALL data after the 2nd period. As you can see from the formula I need the first numbers to output in 5 digits, the next numbers after the first period output in 6 digits, and the ones after the 2nd should output in 3 digits

In short the output SHOULD look like 00000.000000.000 even if someone puts 0.0.0.0.0.0.0.0; HOWEVER, it's currently capturing everything after the 2nd period so in reality it actually looks like 00000.000000.0.0.0.0.0.0

Is there anything I can add to make it cut off the output once it reaches a third period? I would use a regular split function, but when people are inputting data sometimes they put 0000.000000.000.0.0.0.0.0 sometimes they put 00000.000000.000.0.0.0.0 sometimes they put 0000.000000.000. many different combinations, but the separation point is always the period and the end result always needs to be 5digits.6digits.3digits

Let me know if I need to clarify any further.

我认为以下内容将为您提供所需的东西。

=TEXT(LEFT(A2,FIND(".",A2)-1),"00000")&"."&TEXT(MID(A2,FIND(".",A2)+1,FIND(".",A2,FIND(".",A2)+1)-FIND(".",A2)-1),"000000")&"."&TEXT(MID(A2,FIND(".",A2,FIND(".",A2)+1)+1,3),"000")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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