Link to home
Start Free TrialLog in
Avatar of ExpExchHelp
ExpExchHelpFlag for United States of America

asked on

How to turn formula into UDF?

I use a formula (see below) to extract a string that is contained between double/single quotes.

=MID(A1,FIND(")",A1,1)+2,45)

How to I change this formula into a UDF?

Function "ExtractTitle"
...
...
End Function

Btw, the currently formula includes the "" and ' ' upon extraction.   I really only need the text in between.   Any suggestions as to how the double/single quotes can be removed from the output?

EEH
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

This finds the first string between double quotes:
Function ExtractTitle(strText As String) As String
    Dim strParts() As String
    
    strParts = Split("x" & strText, """") '"x" copes with case of " in position 1
    ExtractTitle = strParts(1)
End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Why would you want to use a user-defined function for this?