gpt4 book ai didi

excel - 如何在 Excel 中提取单元格内容的数字部分?

转载 作者:行者123 更新时间:2023-12-04 20:03:54 26 4
gpt4 key购买 nike

我正在处理不同的数据集,并想从 Excel 表中仅提取其中的数字部分。
请问我该怎么做才能只提取数字部分?

例如:

  • "A51sd5dd5$1"我只需要 51551
  • "bd203m01,02"我只需要 2030102

  • 如果您可以提供帮助,我需要一个 Excel 公式或 Vba 函数。
    预先感谢您的帮助

    最佳答案

    欢迎来到论坛!我认为这是您需要具备的功能。
    我测试了您的示例,它们当然以数字形式给出了正确的值。

    这是功能:

    Function GetNumeric(CellRef As String)
    Dim StringLength As Integer
    StringLength = Len(CellRef) 'This is the Length of the CellRef entry

    Dim n As Long
    Dim sResult As String 'Store in a result variable the numeric characters

    For n = 1 To StringLength
    'iterate through each character and test if it is numeric
    If IsNumeric(Mid(CellRef, n, 1)) Then sResult = sResult & Mid(CellRef, n, 1)
    Next n

    'Return your value
    GetNumeric = sResult
    End Function

    我希望它会帮助你!

    关于excel - 如何在 Excel 中提取单元格内容的数字部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61047533/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com