私はVBAで作業しています。私はstring
を取り、それを処理してきれいにされたstring
を返すユーザ定義関数を書いた。私は何が間違っているのか分かりません。私はそれを呼び出すことができず、私の弦を処理してそれを返すように頼むことができません。私はそれを定義したり返す方法に間違いがあると思っています。ExcelでのByRef引数の型の不一致VBA
Public Function ProcessString(input_string As String) As String
' The temp string used throughout the function
Dim temp_string As String
For i = 1 To Len(input_string)
temp_string = Mid(input_string, i, 1)
If temp_string Like "[A-Z, a-z, 0-9, :, -]" Then
return_string = return_string & temp_string
End If
Next i
return_string = Mid(return_string, 1, (Len(return_string) - 1))
ProcessString = return_string & ", "
End Function
そして、私は最後の名前が文字列変数です。この
Worksheets(data_sheet).Range("C2").Value = ProcessString(last_name)
のように、この機能を使用するには、通常、このLastname*****
のように見える、と私はその背後にあるすべての星を削除しようとしています。星なしでLastname
を返してください。
これを実行しようとしたときにCompile error: ByRef arugment type mismatch
が届きました。私はOffice 2003でWindows XPを使用しています。
編集:私が持っているコードの基本的な手順を追加しました。私は同様のコードの約20行を持っています。私が必要とする分野ごとに同じことをする。
Private Sub CommandButton2_Click()
' In my original production code I have a chain of these
' Like this Dim last_name, first_name, street, apt, city, state, zip As String
Dim last_name As String
' I get the last name from a fixed position of my file. Because I am
' processing it from another source which I copied and pasted into excel
last_name = Mid(Range("A4").Value, 20, 13)
' Insert the data into the corresponding fields in the database worksheet
Worksheets(data_sheet).Range("C2").Value = ProcessString(last_name)
rフラグ? – Gaffi
私はそれを呼んだとき、それはライン上に羽ばたく。 'Worksheets(data_sheet).Range(" C2 ")。Value = ProcessString(last_name)' – George