TOP

Automatyczne dzielenie tekstu według podanego separatora

GETSUBSTR() Opis

Poniżej znajdziesz funkcję, która pomoże Ci podzielić tekst na części w oparciu o podany separator.


VBA kod makra

Aby dodać makro otwórz edytor Visual Basic (Alt+F11), wstawić nowy pusty moduł programu (Insert - Module) i skopiuj tam tekst tej funkcji:

Function GETSUBSTR(Txt, Delimiter, n) As String
   Dim x As Variant
      x = Split(Txt, Delimiter)
      If n > 0 And n - 1 <= UBound(x) Then
        GETSUBSTR = x(n - 1)
      Else
        GETSUBSTR = ""
      End If
End Function

Zapisz i wróć do Excel. Teraz w funkcjach niestandardowych możesz znaleźć naszą funkcję GETSUBSTR().

GETSUBSTR(tekst; ogranicznik; numer kolejny fragmentu)

Gdzie:

Artykuły na ten temat: