EXCEL中有任何与数字分开的文字吗?

时间:2013-10-09 20:45:16

标签: regex string excel function

我的意思是例如在A1:123b中最好将123放到B,将“b”放到C列。有什么功能吗?

2 个答案:

答案 0 :(得分:6)

如果数字始终在开头,那么,对于数字:

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

和字母:

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

公式中的" 20"只需要一些大于您可能正在处理的最长字符串长度的数字。

答案 1 :(得分:1)

如果您只想获取值的数字部分(假设为A1),请使用数组公式(输入公式后的control-shift-enter):

=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))

该公式执行以下操作:

  • 对于每个字母,找到字符串
  • 中字符的第一个索引
  • 如果找不到该字符串,则假定该值为长度(未找到)
  • 找到指数的最小值
  • 从第一个字符开始,到第一个字母
  • 之前结束的子字符串
  • 获取文本的数值(此时应为全数字)

获取文本部分:

=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))))