現在、列のセルから入力を受け取り、テキストとスペースを削除し、最後の13桁に短縮してから次の列に出力するマクロがあります。入力時にさまざまな関数を実行してセルに出力
以前の質問でregexを使ってテキストを削除するコードを表示しました(これまでは削除されていたスペースがありました)。しかし、私はどのように関数を実行し、現在のコードでセルに出力することができないのか分かりません。
現在、すべての機能は13桁に短縮されているため、関数が正しく実行/呼び出されていないと思います。
現在のマクロは次のとおりです。
Sub RemoveSpaces_Click()
i = 7
j = 7
Do While ActiveWorkbook.ActiveSheet.Cells(i, 1) <> ""
InputString = ActiveWorkbook.ActiveSheet.Cells(i, 1)
removeAlpha (InputString) ' <--- How to call this?
' Right() after removing to avoid text counting as length
InputString = Right(InputString, 13)
j = j + 1
' Output to second column to preserve original input
ActiveWorkbook.ActiveSheet.Cells(i, 2) = InputString
i = i + 1
Loop
End Sub
Function removeAlpha(strInput As String) As String
strInput = Replace(strInput, " ", "")
With CreateObject("vbscript.regexp")
.Pattern = "[A-Za-z]"
.Global = True
removeAlpha = .Replace(strInput, "")
End With
End Function
'InputString = removeAlpha(InputString) ' –