简体   繁体   中英

There is any function in EXCEL which is separate text from number?

I mean for example in A1: 123b maybe the best put 123 to B and "b" for C column. Any function for that?

If the numbers are always at the beginning, then, for the numbers:

=LOOKUP(9.9E+307,--LEFT(A1,ROW(INDIRECT("1:20"))),LEFT(A1,ROW(INDIRECT("1:20"))))

and for the letters:

   =MID(A1,LEN(LOOKUP(9.9E+307,--LEFT(A1,ROW(INDIRECT("1:20"))),LEFT(A1,ROW(INDIRECT("1:20")))))+1,20)

The "20"'s in the formulas just needs to be some number that is larger than the length of the longest string you might be processing.

If you just want to get the number part of the value (assumed to be in A1), use the array formula (control-shift-enter after entering the formula):

=VALUE(LEFT(A1,MIN(IFERROR(SEARCH({"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"},A1),LEN(A1)))-1))

The formula does the following:

  • for each letter, find the first index of the character in the string
  • if the string is not found, assume the value is the length (not found)
  • find the minimum of the indices
  • take the substring starting from the first character and ending just before the first letter
  • get the numeric value for the text (which should be all-digits at this point)

To get the text part:

=RIGHT(A1,LEN(A1)+1-MIN(IFERROR(SEARCH({"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"},A1),LEN(A1))))

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