1

Can anyone provide the regex for extracting the data between the 2nd and the 3rd "|"

For example, for the below data

2016 Annual | 1.1 - 12.31 | COH (NP) | #21485

The result should be COH (NP)

Community
  • 1
  • 1
Sivas316
  • 13
  • 3
  • 5
    http://stackoverflow.com/questions/22542834/how-to-use-regular-expressions-regex-in-microsoft-excel-both-in-cell-and-loops – Scott Craner Nov 28 '16 at 19:50

1 Answers1

2

A regex is overkill for this. Just split on "|" and take the desired component:

Sub test()
    Dim S As String
    S = "2016 Annual | 1.1 - 12.31 | COH (NP) | #21485"
    Debug.Print Split(S, "|")(2) 'prints COH (NP)
End Sub
John Coleman
  • 51,337
  • 7
  • 54
  • 119