0

I have a text that is segregated with "/" and I need to get some parts of it.

Operator is my variable that gets the main text from the system.

The text is segregated with "/", so for example I need to get the text between the 2nd and 3rd "/".

Ex1: Main text: 40 XY3131Z/9'6"/ABC/OWN/STL/VENT/8741 column1:ABC

Ex2: Main text: 40 AB/9'6"/ABC/OWN/STL/VENT/8741 column1:ABC

Note: The main text is variable, so I cannot use only = Left or Right It need to be with VBA

1 Answers1

0

Please, use the next function:

Function getText(strTxt As String) As String
    getText = Split(strTxt, "/")(2)
End Function

It can be tested in the next way:

Sub testGetText()
   Dim x As String
   x = "40 XY3131Z/9'6""/ABC/OWN/STL/VENT/8741" 'the double double quote is to be able to write it in VBA. If the string is in a cell, it may look as you show it...
   MsgBox getText(x)
End Sub

Or as UDF (user defined function) from a cell:

 =getText(A1)

Of course, in A1 should be the text where to extract the string you need...

FaneDuru
  • 38,298
  • 4
  • 19
  • 27