ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User Defined Worksheet Functions? (https://www.excelbanter.com/excel-programming/291777-user-defined-worksheet-functions.html)

brad

User Defined Worksheet Functions?
 
Can I compose a function in VBA and refer to it in a
formula?

Let's say A1 has the text: "aja,ajsd," and I want to use a
formula to call the function I've created:
=ParseComma(A1)
or perhaps qualifying it more? =Module1.ParseComma(A1)
to return "ajaajsd" to the field?

If I can't, why not? Can Add-ins do it?

Thanks for the info.

-Brad

PS: I'm not interested in a solution to parse a comma, but
thanks. :)

Bob Phillips[_6_]

User Defined Worksheet Functions?
 
Yes you can do exactly what you have described.

Did you try it and get a problem then ?

By the way, an add-in is just another workbook where there are no visible
worksheets, it can have functions subs and even data as any other worksheet.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Brad" wrote in message
...
Can I compose a function in VBA and refer to it in a
formula?

Let's say A1 has the text: "aja,ajsd," and I want to use a
formula to call the function I've created:
=ParseComma(A1)
or perhaps qualifying it more? =Module1.ParseComma(A1)
to return "ajaajsd" to the field?

If I can't, why not? Can Add-ins do it?

Thanks for the info.

-Brad

PS: I'm not interested in a solution to parse a comma, but
thanks. :)




Harald Staff

User Defined Worksheet Functions?
 
Sure. Open VB editor (Alt F11 or similar). menu Insert Module. Then type something like

Function RemoveStuff(FromWhat As String, _
RemoveWhat As String) As String
RemoveStuff = Replace$(FromWhat, RemoveWhat, "")
End Function

(Note all the declarations, here all As String)

Then return to a worksheet. In A1 type ABCD. In B1 type
=RemoveStuff(A1,"C")
You'll also find it under Insert Function category Custom or User Defined.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Brad" wrote in message
...
Can I compose a function in VBA and refer to it in a
formula?

Let's say A1 has the text: "aja,ajsd," and I want to use a
formula to call the function I've created:
=ParseComma(A1)
or perhaps qualifying it more? =Module1.ParseComma(A1)
to return "ajaajsd" to the field?

If I can't, why not? Can Add-ins do it?

Thanks for the info.

-Brad

PS: I'm not interested in a solution to parse a comma, but
thanks. :)





All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com