-5
同じセルに都市と住所を持つデータセットがあります。都市を削除したいのですが、通常はカンマ区切りの最後の値です。セルその隣 exampleVBAコンマ区切りセル、最後の入力が必要です
同じセルに都市と住所を持つデータセットがあります。都市を削除したいのですが、通常はカンマ区切りの最後の値です。セルその隣 exampleVBAコンマ区切りセル、最後の入力が必要です
私はあなたのイメージを見ることはできませんが、あなたの説明の後、次の機能を探しています:それを使用する方法の
Function Remove_last_part(StrCommaSeparated As String) As String
Dim arr() As String
Dim i As Integer
arr = Split(StrCommaSeparated, ",") ' make an array out of the comma separated string
ReDim Preserve arr(UBound(arr) - 1) ' Remove the last array element, by redimensioning the array to it's total elements minus 1
Remove_last_part = Join(arr, ",") ' make a comma separated string out of the redimensionned array
End Function
例:
Public Sub TestIt()
Dim strTest As String
strTest = "anything,anywhen,anyhow,New York"
Debug.Print "BEFORE -->" & strTest
Debug.Print "AFTER -->" & Remove_last_part(strTest)
End Sub
ウィル出力:
BEFORE -->anything,anywhen,anyhow,New York AFTER -->anything,anywhen,anyhow
ありがとうございました!私のやや基本的な質問に対する謝罪! –
あなたはスプリット機能を使用することができ、http://www.exceltrick.com/formulas_macros/vba-split-function/ – user1844933