Skip to content

Instantly share code, notes, and snippets.

@froop
Created May 9, 2011 15:00
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 froop/962675 to your computer and use it in GitHub Desktop.
Save froop/962675 to your computer and use it in GitHub Desktop.
[Excel] 文字を差し替えるマクロ雛形
'使用方法:
'セルに数式として「=ReplaceChar(A1)」のように記述
Option Explicit
'変換対象文字の定義
Const CONV_SRC = "ガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポヰヱヲヴァィゥェォッャュョヮ"
Const CONV_TGT = "カキクケコサシスセソタチツテトハヒフヘホハヒフヘホイエオウアイウエオツヤユヨワ"
'処理main
Function ReplaceChar(strText As String) As String
Dim I, J As Integer
ReplaceChar = ""
For I = 1 To Len(strText)
Dim strChar As String
strChar = Mid(strText, I, 1)
For J = 1 To Len(CONV_SRC)
If strChar = Mid(CONV_SRC, J, 1) Then
strChar = Mid(CONV_TGT, J, 1)
Exit For
End If
Next J
ReplaceChar = ReplaceChar & strChar
Next I
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment