本文介绍了Excel如何删除电子表格中每个单词开头的数字和斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何删除每个单词开头的数字和斜杠
Hi how can I remove number and slash at the beginning of each words
这是截图
提前感谢。
推荐答案
尝试此代码:
Sub Test()
Dim CL As Range, CLv As String, a As Long
For Each CL In ActiveSheet.UsedRange
CLv = CL.Value
On Error Resume Next
a = WorksheetFunction.Search("/", CLv)
On Error GoTo 0
If a <> 0 Then
CL.Value = Right(CLv, Len(CLv) - a)
a = 0
End If
Next
End Sub
修改:
或者这个代码(仅当单元格值以数字开始时才删除):
Or this code (only delete if cell value start with numbers):
Sub Test2()
Dim CL As Range, CLv As String, a As Long
For Each CL In ActiveSheet.UsedRange
CLv = CL.Value
a = InStr(1, CLv, "/")
If a <> 0 Then
If IsNumeric(Left(CLv, a - 1)) Then
CL.Value = Right(CLv, Len(CLv) - a)
End If
End If
Next
End Sub
这篇关于Excel如何删除电子表格中每个单词开头的数字和斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!