Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MintJulep 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
Joined
Apr 2, 2020
Messages
20
Location
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.
 
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