Excel中利用函数提取数字的操作技巧
时间:2023-09-07 18:45:21
许多熟悉Excel进行数据处理的网友都会深刻的感受到这款软件功能的强大,尤其是如果会使用函数的话,今天,小编就教大家在Excel中利用函数提取数字的操作技巧。
Excel中利用函数提取数字的操作步骤
汉字在前,数字在后面的情形。可以用MID,min, find三个函数来实现提取里面的数字。如图:在B2输入“=MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&“0123456789”)),20)”
把单元格里面所有的数字都提出来。可以使用宏。先打开VBA编辑器。工具——宏——visual basic 编辑器
在编辑器里点击插入——模块。在模块那里输入如下代码:
Function zzsz(xStr As String) As StringDim i As IntegerFor i = 1 To Len(xStr)If IsNumeric(Mid(xStr, i, 1)) Then zzsz = zzsz & Mid(xStr, i, 1)NextEnd Function
回到工作表,在B2单元格那里输入“=zzsz(A2)”。就可以用VBA把A2单元格里所有的数字都提取出来了,如图所示。
指定从第几个数组提取开始。也就是说在不连续的那些数字中,从第几次出现的数组开始提取。同样在模块那里输入如下代码:
Function GetNums(rCell As Range, num As Integer) As StringDim Arr1() As String, Arr2() As StringDim chr As String, Str As StringDim i As Integer, j As IntegerOn Error GoTo line1
Str = rCell.TextFor i = 1 To Len(Str)chr = Mid(Str, i, 1)If (Asc(chr) 《 48 Or Asc(chr) 》 57) ThenStr = Replace(Str, chr, “ ”)End IfNext
Arr1 = Split(Trim(Str))ReDim Arr2(UBound(Arr1))For i = 0 To UBound(Arr1)If Arr1(i) 《》 “” ThenArr2(j) = Arr1(i)j = j + 1End IfNext
GetNums = IIf(num 《= j, Arr2(num – 1), “”)line1:End Function
在回到单元格那里输入“=Getnums(A3,2)”就可以提取第几次出现的数组了,如图所示。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
excel表格底纹如何设置
Win10怎么打开系统服务管理器 Win10打开系统服务管理器操作方法
![](https://img.aspxhome.com/file/2023/26/a224613_0s.jpg)
Excel表格如何设置密码
“禁用驱动程序强制签名”解决Win10无法安装驱动的问题
![](https://img.aspxhome.com/file/2023/30/a263467_0s.jpg)
Win7系统重装后鼠标失灵怎么办?Win7重装鼠标失灵解决方法
![](https://img.aspxhome.com/file/2023/1/a273456_0s.png)
WPS办公助手怎么打开,如何使用
![](https://img.aspxhome.com/file/2023/9/a184489_0s.jpg)
word2013中怎样设置复选框与正文对齐
![](https://img.aspxhome.com/file/2023/6/18846_0s.jpg)
Wps表格来生成面积图的操作方法
Blender怎么去除阴影?去除阴影的操作方法
![](https://img.aspxhome.com/file/2023/7/a332156_0s.jpg)
Win10“我的电脑”图标没了怎么办?找回“我的电脑”图标的方法
![](https://img.aspxhome.com/file/2023/1/a275951_0s.png)
win7系统下在视频网站上看视频时会出现绿屏现象问题
![](https://img.aspxhome.com/file/2023/29/a254499_0s.png)
重装Win10系统时开机反复蓝屏怎么解决?
![](https://img.aspxhome.com/file/2023/26/a222174_0s.jpg)
苹果或将在Apple One中整合Podcasts+播客订阅服务
![](https://img.aspxhome.com/file/2023/0/a207470_0s.jpeg)
WPS怎么做三角形时间轴?WPS时间轴样式的做法步骤
![](https://img.aspxhome.com/file/2023/9/a182019_0s.png)
如何在Mac上更改WiFi网络的优先级 ?
![](https://img.aspxhome.com/file/2023/4/a208334_0s.png)
QQ五笔输入法如何同步词库
![](https://img.aspxhome.com/file/2023/5/a318219_0s.jpg)
淘宝叠猫猫怎么获取合合卡?淘宝叠猫猫合合卡能送人吗?
![](https://img.aspxhome.com/file/2023/8/a333445_0s.jpg)
excel柱状图排序的方法
在wps表格中怎样统一设置日期格式
如何在WPS中打印反字
![](https://img.aspxhome.com/file/2023/6/a164556_0s.jpg)