Created
May 9, 2011 15:00
-
-
Save froop/962675 to your computer and use it in GitHub Desktop.
[Excel] 文字を差し替えるマクロ雛形
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'使用方法: | |
'セルに数式として「=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