exce利用自定义函数去掉字符串中的数字
时间:2023-02-20 10:59:14
如果要去掉某个字符串中的所有数字,例如将一个字符串“Excel123”去掉数字后变为“Excel”,可以用自定义函数来实现。按Alt+F11打开VBA编辑器,单击菜单“插入→模块”,在右侧的代码窗口中输入自定义函数:
Function RemoveNums(theString As String)
Dim eachChar, Temp As String
Dim i As Integer
Temp = ""
For i = 1 To Len(theString)
eachChar = Mid(theString, i, 1)
If Asc(eachChar) < 48 Or Asc(eachChar) > 57 Then
Temp = Temp & eachChar
End If
Next
RemoveNums = Temp
End Function
假如包含数字的字符串在A1单元格,在B1单元格中输入
=RemoveNums(A1)
即可返回一个去掉数字后的字符串,如果字符串全部由数字组成,则返回空字符串。
标签:去掉,字符串,数字,自定义,Excel函数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
excel让不同类型数据用不同颜色显示
2023-09-30 17:31:36
用EXCEL在二维表查找数据-Excel教程-
2022-04-18 04:15:14
Excel中怎么筛选显示前3名
2023-09-08 02:47:44
![](https://img.aspxhome.com/file/2023/4/a153914_0s.png)
Win10系统怎么设置系统睡眠时间?Win10系统设置系统睡眠时间的方法
2022-01-19 06:00:17
![](https://img.aspxhome.com/file/2023/0/52800_0s.png)
excel表格内加法操作的教程
2022-03-27 13:45:27
excel表格中如何快速删除空白行
2022-01-16 00:02:52
Word中巧用查找替换功能制作试卷
2022-09-29 09:47:51
Excel图表3个小招,图表秒更新
2022-04-04 07:05:27
![](https://img.aspxhome.com/file/2023/1/a142011_0s.png)
如何在Word 2019中自定义文本搜索?
2023-02-07 11:57:47
Excel表格如何快速筛选?
2023-03-12 07:39:09
![](https://img.aspxhome.com/file/2023/2/55202_0s.gif)
word中的占位符在哪? word插入占位符文本的教程
2022-05-01 14:51:12
![](https://img.aspxhome.com/file/2023/3/22753_0s.jpg)
Win10检测到移动硬盘插入但是为什么不显示盘符?
2023-11-16 09:45:07
![](https://img.aspxhome.com/file/2023/4/49164_0s.jpg)
Word中10个让你提升工作效率的技巧
2023-05-20 08:59:48
![](https://img.aspxhome.com/file/2023/4/33634_0s.jpg)
excel如何固定某一行
2022-01-25 23:53:20
如何设置word等宽两栏
2022-08-06 12:45:48
![](https://img.aspxhome.com/file/2023/3/33193_0s.png)
Word段前段后间距的设置
2023-12-13 07:52:25
![](https://img.aspxhome.com/file/2023/9/21469_0s.gif)
word翻译文字怎么使用?word翻译文字功能使用方法
2023-01-15 11:00:01
![](https://img.aspxhome.com/file/2023/7/26847_0s.jpg)
如何在Word 2019中对齐和缩进段落?
2022-06-17 07:37:26
![](https://img.aspxhome.com/file/2023/4/23024_0s.png)
Win10为什么搜索不到共享打印机?
2023-12-12 23:16:52
![](https://img.aspxhome.com/file/2023/6/51226_0s.jpg)
msvcp140.dll丢失如何修复?Win10系统msvcp140.dll丢失修复方法
2023-11-15 03:46:09
![](https://img.aspxhome.com/file/2023/2/49282_0s.jpg)