Excel - 将字符串转换为URL友好

时间:2013-06-25 13:08:04

标签: excel

我试图转换字符串,例如全世界都是一个舞台

进入更友好的网址,例如所有最世界-A-阶段

到目前为止,我知道我可以使用Lowercase并用空格替换破折号但是有更合适的方法来删除标点符号/非URL友好字符

1 个答案:

答案 0 :(得分:0)

How to remove non-alphanumeric characters in Excel

Option Explicit
Function Alpha(rg As Range) As String
Dim i As Integer
If rg.Count <> 1 Then
MsgBox ("Only a single cell allowed as argument")
Exit Function
End If
For i = 1 To Len(rg.Text)
Select Case Asc(Mid(rg.Text, i, 1))
Case 48 To 57, 65 To 90, 97 To 122
Alpha = Alpha & Mid(rg.Text, i, 1)
End Select
Next i
End Function