If your code doesn't have space then the below code will help.
Sub Test()
Data = "A850085_MDC-WP-01003_SRI Phase 2 - Programme Manager - Dionysios Psachoulias"
startpos = InStr(Data, "WP")
If startpos = 0 Then startpos = InStr(Data, "MD")
fisrtNumPos = 0
LastNumPos = 0
For i = startpos To Len(Data)
If fisrtNumPos = 0 And LastNumPos = 0 Then
If IsNumeric(Mid(Data, i, 1)) Then
fisrtNumPos = i
End If
Else
If Not IsNumeric(Mid(Data, i, 1)) Then
LastNumPos = i
Exit For
End If
End If
Next i
Endpos = LastNumPos - startpos
Debug.Print Mid(Data, startpos, Endpos)
End Sub
This should work now. But if the text contains "MD" followed by "WP" then it will take the code from WP only.
for example:
data= "A850085_WPC-MD-01003_SRI Phase 2 - Programme Manager - Dionysios Psachoulias"
then the result will be
result= "WPC-MD-01003"