# extract string from column

I have the following situation:

I have a column that is contains the following data (string):

A0000AXYZTI00
A0000A12345TI00
etc..

I need to obtain the string value that starts with the 2nd 'A' and ends before the 'T'
So in this case it would be AXYX abd A12345. Sometimes the length between the 2nd A and the T varies. Is there an easy way of doing this with some sort of string function?

Many thanks.
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Dear,

Something like this should work :

``````text = "A0000AXYZTI00"

long_text = Len(text)

pos_t = Instr (1, text , "T")
pos_2nd_a = Instr (2, text , "A")

value = Mid("A0000AXYZTI00", pos_2nd_a+1, pos_t-pos_2nd_a)
``````

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
in query
Select Mid("A0000AXYZTI00", Instr (2, text , "A")  +1 ,Instr (1, text , "TI00") )
Author Commented:
I just tried value: Mid([MFAnumber], Instr (2, [MFAnumber], "A")  +1 ,Instr (1, [MFAnumber], "TI00") ) but it does not return the right values.
Commented:
Something like this, perhaps:
``````Function Splitter(str)
Dim ra
Dim rb

ra = Split(str, "T") '' "T" segment(s)
rb = Split(ra(0), "A") '' "A" segment(s)

Splitter = "A" & rb(2) '' Return value
End Function

MsgBox Splitter("A0000AXYZTI00") '' "AXYZ"
MsgBox Splitter("A0000A12345TI00") '' "A12345"
``````
Commented:
Select Mid([MFAnumber], Instr(2, [MFAnumber], "A")+1 ,Instr(1,[MFAnumber], "T")- Instr(2, [MFAnumber], "A")-1)
Commented:
You want concise? You get concise!

Put this in a module:
``````Function Splitter(ByVal str As String) As String
Splitter = "A" & Split(Split(str, "T")(0), "A")(2)
End Function
``````
Assume

A1 = "A0000AXYZTI00"

and

A2 = "A0000A12345TI00"

Enter
``````=Splitter(A1)
``````
into B1 and copy it down to B2.
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.