自定義函數提取字符串中的數字
Function GetNB(rng As Range)
If rng <> "" Then
For i = 1 To Len(rng)
tmp = Mid(rng, i, 1)
If IsNumeric(tmp) Or tmp Like "[+-\*\/^%)()]" And Not tmp Like "[A-Z?!~@=_,;|\[]" Then GetNB = GetNB & tmp
Next
Else
GetNB = ""
End If
End Function
若使運算式自動計算,則用以下代碼
【EXCEL 自定義函數提取字符串中的數字】Function CountNB(rng As Range)
If rng <> "" Then
For i = 1 To Len(rng)
tmp = Mid(rng, i, 1)
If IsNumeric(tmp) Or tmp Like "[+-\*\/^%()]" And Not tmp Like "[A-Z?!~@=_,;|\[]" Then CountNB = CountNB & tmp
Next
CountNB = Application.Evaluate(CountNB)
Else
CountNB = ""
End If
End Function
猜你喜歡
- excel中怎么用AVERAGE函數求幾種平均值
- Excel中將數字轉化為列標字母的公式
- excel用公式獲取工作簿名稱及路徑
- 利用Excel對篩選結果計數的簡單方法
- Excel引用其他工作表數據的幾種方法概述
- excel用隱藏函數DATEDIF計算兩個日期之間的天數
- excel怎么將數組公式中的TRUE或FALSE轉化為1或0
- excel提取字符串中數字、中文、英文字符的自定義函數
- 通過Excel的DB函數計算資產折舊
- 怎么在excel編輯欄中快速選擇函數的參數
