excel - 使用条件从excel中的字符串中提取数字
解决方案
恭喜,今天是您将一些vba知识添加到您的武器库的日子。如果您向其中添加 vba 公式,结果将如下所示:
要添加公式,请按Alt+F11并将以下代码粘贴到Modul1
或 中Worksheet
:
Public Function ExtractString(myRange As Range) As String
Dim i As Long
Dim result As String
Dim currentString As String
Dim okIndex As Long
okIndex = 1
result = ""
For i = 1 To Len(myRange.Text)
currentString = Mid(myRange.Text, i, 1)
If IsNumeric(currentString) And okIndex >= 1 Then
result = result & currentString
okIndex = okIndex + 1
Else
If okIndex > 1 Then okIndex = -1
End If
Next
ExtractString = result
End Function
推荐阅读
- c# - 如何确定 HttpWebRequest 异常是来自代理还是目标服务器?
- python - 微软文档休息 api
- python - 如何矢量化比较来自两个不同数据帧的形状对象的函数?
- r - 加入和合并仅在 R 中部分和完全工作
- reactjs - 在 webpack 包分析器中看到延迟加载的模块是否正常?
- wordpress - wordpress 网站中的外部表单
- angular - 如何解决 ENOENT:没有这样的文件或目录,在具有多个项目的工作区中使用 ngx-build-plus 打开“\package.json”?
- sql-server - T-SQL 处理自定义 XML
- python - 识别 P&F 图表中最后一列包含三个或更多“X”图的股票
- json - 获取问题:'_InternalLinkedHashMap
' 不是类型 'List 的子类型 '