raym
raym

Reputation: 13

EXTRACT PORTION OF STRING IN A CELL

I would like to extract string after an "_".

Here is my data:

data                       
3CC1P01_1 1/2"_ST 25_B31.3

And Desired output should be like this:

data                         c1       c2       c3       c4
3CC1P01_1 1/2"_ST 25_B31.3   3CC1P01  1 1/2"   ST 25    B31.3

Upvotes: 0

Views: 49

Answers (1)

June7
June7

Reputation: 21370

String manipulation functions Left, Mid, InStr, InStrRev can easily extract C1 and C4. Gets complicated for the other parts. Build a VBA function.

Function GetString(strS As String, intP As Integer) As String
Dim strAry As Variant
strAry = Split(strS, "_")
GetString = strAry(intP - 1)
End Function

Call function from query or textbox for each of the desired parts.
GetString([fieldname], 1)

Upvotes: 1

Related Questions