0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

5月のVBAユーザー定義関数

Posted at
'配列取り出し
Function GetItemByIndex(inputStr As String, index As Integer) As String
    Dim items() As String
    items = Split(inputStr, ",")
    
    If index >= 1 And index <= UBound(items) + 1 Then
        GetItemByIndex = items(index - 1)
    Else
        GetItemByIndex = ""
    End If
End Function

'配列重複削除
Function RemoveDuplicatesCSV(inputStr As String) As String
    Dim items() As String
    Dim dict As Object
    Dim i As Integer
    Dim result As String

    Set dict = CreateObject("Scripting.Dictionary")
    items = Split(inputStr, ",")

    For i = LBound(items) To UBound(items)
        If Not dict.exists(Trim(items(i))) Then
            dict.Add Trim(items(i)), True
        End If
    Next i

    RemoveDuplicatesCSV = Join(dict.keys, ",")
End Function
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?