• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

EXCEL UDF with IF/ELSE

Hi Guys,


I have created two separate UDF in VBA that parse the "Dear" and "Your / To" from a block of text to leave just the forename and surname. Unfortunately, they are separate.

I am looking to create one UDF with IF ELSE so it returns the forename and surname when it finds either "To" or "Your" based on the one custom UDF.

Is that possible?
 

Attachments

  • Book1.xlsm
    18.2 KB · Views: 3
Mikeyabosbht2021
You should reread Forum Rules
... and You'll soon remember clear sentences about Cross-posting.
Those rules are for You too.
HInt: Same kind of rules are in every Forum.
 
Posted this solution at OzGrid, will only work if the text is formatted as in the example:


Code:
Function GetName3(target As String)
x = InStr(1, target, Chr(10))
If Left(target, 4) = "Dear" Then
GetName3 = Trim(Mid(target, 5, x - 5))
Else
GetName3 = Trim(Mid(target, 1, x - 1))
End If
End Function
 
Back
Top