Skip to content

Instantly share code, notes, and snippets.

@sharapeco
Created May 21, 2013 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharapeco/5617768 to your computer and use it in GitHub Desktop.
Save sharapeco/5617768 to your computer and use it in GitHub Desktop.
半角カナを全角に、全角英数字を半角にだいたい変換する関数 Excel 用
Private Function NormalizeString(ByVal source As Variant) As Variant
Dim i As Integer
Dim c As Variant
Dim result As Variant
result = ""
For i = 1 To Len(source)
c = StrConv(source, vbWide)
If Mid(c, i, 1) Like "[A-z]" Or Mid(c, i, 1) Like "[0-9]" Or Mid(c, i, 1) Like "-" Then
result = result & StrConv(Mid(c, i, 1), vbNarrow)
Else
result = result & Mid(c, i, 1)
End If
Next i
NormalizeString = result
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment