Excel formula excel将文本和数字分开

Excel formula excel将文本和数字分开,excel-formula,excel-2010,Excel Formula,Excel 2010,这是一个excel问题。我需要在字符串中分隔文本和数字。字符串可以以数字开头,也可以以字符开头。文本或数字之间可能有空格。因此,公式需要具有足够的通用性,以便将其分为两列,其中一列仅包含文本,另一列仅包含数字。请帮忙 多谢各位 文本字符串示例 07 7878 8788 ABC JKSDKJK ABCVG HDH 656688 AGSGD89789798798 798 99AJSUDFK 只要列A中的所有单元格的格式为{numbers+spaces}{non numeric text}或相反,就

这是一个excel问题。我需要在字符串中分隔文本和数字。字符串可以以数字开头,也可以以字符开头。文本或数字之间可能有空格。因此,公式需要具有足够的通用性,以便将其分为两列,其中一列仅包含文本,另一列仅包含数字。请帮忙

多谢各位

文本字符串示例

  • 07 7878 8788 ABC JKSDKJK
  • ABCVG HDH 656688
  • AGSGD89789798798
  • 798 99AJSUDFK

只要列A中的所有单元格的格式为{numbers+spaces}{non numeric text}或相反,就可以从查找每个单元格中第一个数字字符和第一个非数字、非空格字符的位置开始。然后,您可以使用这些加上一点额外的逻辑来使用
MID
提取适当的子字符串

我在这里发布了数组公式:

您需要稍微修改第二个公式,以便它返回第一个字符的位置,而不是数字或空格:

=MIN(
        IF(
                  1*ISNUMBER(
                  1*MID(
                      A1,
                      ROW(INDIRECT("A1:A"&LEN(A1))),
                      1
                  )
                ) +
                1*(MID(
                      A1,
                      ROW(INDIRECT("A1:A"&LEN(A1))),
                      1
                  )=" "),
            LEN(A1)+1,
            ROW(INDIRECT("A1:A"&LEN(A1)))

        )
    )

只要列A中的所有单元格的格式为{numbers+spaces}{non numeric text}或相反,就可以从查找每个单元格中第一个数字字符和第一个非数字、非空格字符的位置开始。然后,您可以使用这些加上一点额外的逻辑来使用
MID
提取适当的子字符串

我在这里发布了数组公式:

您需要稍微修改第二个公式,以便它返回第一个字符的位置,而不是数字或空格:

=MIN(
        IF(
                  1*ISNUMBER(
                  1*MID(
                      A1,
                      ROW(INDIRECT("A1:A"&LEN(A1))),
                      1
                  )
                ) +
                1*(MID(
                      A1,
                      ROW(INDIRECT("A1:A"&LEN(A1))),
                      1
                  )=" "),
            LEN(A1)+1,
            ROW(INDIRECT("A1:A"&LEN(A1)))

        )
    )
仅文本

函数Alphas(ByVal strInString作为字符串)作为字符串 幽幽如弦,悠长如弦 尺寸i与长度相同,strTmp与字符串相同

lngLen = Len(strInString)
strOut = ""
For i = 1 To lngLen
    strTmp = Left$(strInString, 1)
    strInString = Right$(strInString, lngLen - i)
    'The next statement will extract BOTH Lower and Upper case chars
    If (Asc(strTmp) >= 65 And Asc(strTmp) <= 90 Or Asc(strTmp) >= 97 And Asc(strTmp) <= 122) Then
        'to extract just lower case, use the limit 97 - 122
        'to extract just upper case, use the limit 65 - 90
        strOut = strOut & strTmp
    End If
Next i
Alphas = strOut
lngLen = Len(strInString)
strOut = ""
For i = 1 To lngLen
    strTmp = Left$(strInString, 1)
    strInString = Right$(strInString, lngLen - i)
    If (Asc(strTmp) >= 48 And Asc(strTmp) <= 57) Then
        strOut = strOut & strTmp
    End If
Next i
Numerics = strOut
lngLen = Len(strInString)
strOut = ""
For i = 1 To lngLen
    strTmp = Left$(strInString, 1)
    strInString = Right$(strInString, lngLen - i)
    'The next statement will extract BOTH Lower and Upper case chars
    If (Asc(strTmp) >= 65 And Asc(strTmp) <= 90 Or Asc(strTmp) >= 97 And Asc(strTmp) <= 122 or Asc(strTmp) >= 48 And Asc(strTmp) <= 57) Then
        'to extract just lower case, use the limit 97 - 122
        'to extract just upper case, use the limit 65 - 90
        strOut = strOut & strTmp
    End If
Next i
Alphanumerics = strOut
lngLen=Len(strInString)
strOut=“”
对于i=1至lngLen
strTmp=Left$(strInString,1)
strInString=右$(strInString,lngLen-i)
'下一条语句将同时提取小写和大写字符
如果(Asc(strTmp)>=65和Asc(strTmp)=97和Asc(strTmp)=48和Asc(strTmp)仅文本

函数Alphas(ByVal strInString作为字符串)作为字符串 幽幽如弦,悠长如弦 尺寸i与长度相同,strTmp与字符串相同

lngLen = Len(strInString)
strOut = ""
For i = 1 To lngLen
    strTmp = Left$(strInString, 1)
    strInString = Right$(strInString, lngLen - i)
    'The next statement will extract BOTH Lower and Upper case chars
    If (Asc(strTmp) >= 65 And Asc(strTmp) <= 90 Or Asc(strTmp) >= 97 And Asc(strTmp) <= 122) Then
        'to extract just lower case, use the limit 97 - 122
        'to extract just upper case, use the limit 65 - 90
        strOut = strOut & strTmp
    End If
Next i
Alphas = strOut
lngLen = Len(strInString)
strOut = ""
For i = 1 To lngLen
    strTmp = Left$(strInString, 1)
    strInString = Right$(strInString, lngLen - i)
    If (Asc(strTmp) >= 48 And Asc(strTmp) <= 57) Then
        strOut = strOut & strTmp
    End If
Next i
Numerics = strOut
lngLen = Len(strInString)
strOut = ""
For i = 1 To lngLen
    strTmp = Left$(strInString, 1)
    strInString = Right$(strInString, lngLen - i)
    'The next statement will extract BOTH Lower and Upper case chars
    If (Asc(strTmp) >= 65 And Asc(strTmp) <= 90 Or Asc(strTmp) >= 97 And Asc(strTmp) <= 122 or Asc(strTmp) >= 48 And Asc(strTmp) <= 57) Then
        'to extract just lower case, use the limit 97 - 122
        'to extract just upper case, use the limit 65 - 90
        strOut = strOut & strTmp
    End If
Next i
Alphanumerics = strOut
lngLen=Len(strInString)
strOut=“”
对于i=1至lngLen
strTmp=Left$(strInString,1)
strInString=右$(strInString,lngLen-i)
'下一条语句将同时提取小写和大写字符

如果(Asc(strTmp)>=65,Asc(strTmp)=97,Asc(strTmp)=48,Asc(strTmp),你可以使用一些嵌套版本的replace()将所有数字替换为“”,基本上删除它们,只留下字母。我尝试使用类似于=TRIM的公式(LEFT(A1,MIN)(FIND({1,2,3,4,5,6,7,8,9,0},A1&“1,2,3,4,5,7,9,0”)-1))您可以使用replace()的一些嵌套版本将所有数字替换为“”,基本上删除它们并只保留字母。我尝试使用类似于=TRIM的公式(LEFT(A1,MIN(FIND({1,2,3,4,5,7,8,9,0},A1&“1,2,3,4,5,6,7,8,9,0”)-1))