...单元格只保留数字,将字母保存到右列,代码如何编写?
发布网友
发布时间:2024-04-02 07:12
我来回答
共1个回答
热心网友
时间:2024-04-12 13:01
按ALT+F11,插入-模块,复制下列语句
FunctionSplitNumEng(str As String, sty As Byte)
Dim StrA As String
Dim StrB As String
Dim StrC As String
Dim i As Integer
Dim SigS As String
For i = 1 To Len(str)
SigS = Mid(str, i, 1)
If SigS Like "[a-zA-Z]" Then
StrA = StrA & SigS
ElseIf SigS Like "#" Then
StrB = StrB & SigS
Else
StrC = StrC & SigS
End If
Next i
Select Case sty
Case 1
SplitNumEng = StrA
Case 2
SplitNumEng = StrB
Case Else
SplitNumEng = StrC
End Select
EndFunction
比如你的数据在A1
B1输入 =SplitNumEng(A1,1)
C1 =SplitNumEng(A1,2)