TOP

Automatic division of text by the specified separator

YouLibreCalc for Excel logo

GETSUBSTR() Description

Below you will find a function that will help you split the text into parts based on the specified separator.


VBA code for the macro

To add a macro, open the Visual Basic editor (Alt+F11), insert a new empty software module (Insert - Module) and copy the text of this function there:

Function GETSUBSTR(Txt, Delimiter, n) As String
   'moonexcel.com.ua
   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

Save and return to Excel. Now in custom functions you can find our GETSUBSTR() function.

 =GETSUBSTR(text; delimiter; sequence_number_of_fragment) 

where:

Related Articles: