5

I have 1000's of strings similar to "CN=Joe Smith,OU=Students,DC=Domain,DC=Edu" and I want to find the first instance of OU= and remove the characters before it leaving me with "OU=Students,DC=Domain,DC=Edu". How can I do this with an Excel formula?

Many thanks Jamie

Jamie
  • 2,465
  • 10
  • 28
  • 31

2 Answers2

8

Use this:

=RIGHT(A1,LEN(A1)-FIND("OU=",A1)+1)
Somnath Muluk
  • 55,015
  • 38
  • 216
  • 226
jevakallio
  • 35,324
  • 3
  • 105
  • 112
0

I combined jevakallio's answer with How do I recognize “#VALUE!” in Excel spreadsheets? for cases when the key "OU=" doesn't exist in the cell.

Situations:

CN=Joe Smith,OU=Students,DC=Domain,DC=Edu
CN=Jane Doe,DC=Domain,DC=Edu

Right Value checking for missing key:

=IF(ISERROR(RIGHT(A2,LEN(A2)-FIND("OU=",A2)+1)),"OU= Not Found",RIGHT(A2,LEN(A2)-FIND("OU=",A2)+1))

Results:

OU=Students,DC=Domain,DC=Edu
OU= Not Found
Jacksonsox
  • 1,114
  • 15
  • 25