Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search in part number

Status
Not open for further replies.

VojtaR

Automotive
Apr 2, 2020
20
CZ
Hello,

I would like to write simple macro which will search "__" (double underscore) in part number.
Our Part number looks like this:
XXXXXXXXXXXX-XX_XXXX_SOMETHING_SOMETHING_ELSE__WORD1_WORD2_WORD3

I want to get message with
"SOMETHING SOMETHING ELSE" and "WORD1 WORD2 WORD3"

Can someone help me with that please?

Thank you in advance.
 
Replies continue below

Recommended for you

start by searching the forum for relevant info

regards,
LWolf
 
Sub CATMain()

Dim testStr As String
testStr = "XXXXXXXXXXXX-XX_XXXX_SOMETHING_SOMETHING_ELSE__WORD1_WORD2_WORD3"

Dim leftStr As String
leftStr = Left(testStr, InStr(testStr, "__") - 1)

Dim rightStr As String
rightStr = Right(testStr, Len(testStr) - Len(leftStr) - 2)

MsgBox (leftStr & " and " & rightStr)

'Alternatively you could split it and then use the split values.
Dim splitStrArr() As String
splitStrArr = Split(testStr, "__")

MsgBox (splitStrArr(0) & " and " & splitStrArr(1))

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top