ExcelBanter

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

Sean[_7_]

User-Defined Excel Functions
 
Anyone know where I can find info on creating user defined
excel fuctions?

Just as a rudimentary example:
---------------------
Public Function Test(ByVal dAmt As Double) As Double

Test = dAmt * 2

End Function
------------------
This returns the "#VALUE!" error message. Never done an
excel UDF, so I've no idea what I'm doing wrong (or even
right).

Thanks in advance,

Sean

Kevin Stecyk

User-Defined Excel Functions
 
Sean,

I think by definition a UDF has to be by reference. So I would delete hte
"ByVal" and see if it works.

Regards,
Kevin


"Sean" wrote in message
...
Anyone know where I can find info on creating user defined
excel fuctions?

Just as a rudimentary example:
---------------------
Public Function Test(ByVal dAmt As Double) As Double

Test = dAmt * 2

End Function
------------------
This returns the "#VALUE!" error message. Never done an
excel UDF, so I've no idea what I'm doing wrong (or even
right).

Thanks in advance,

Sean




Sean[_7_]

User-Defined Excel Functions
 
Thanks for the help, but it doesn't work either (I had
tried it byref, byval, with nothing).

I have tried boilerplate examples from MS, but they return
the same error.

Is there an option or setting I need to adjust? I can find
nothing under Tools--Options.
-----Original Message-----
Sean,

I think by definition a UDF has to be by reference. So I

would delete hte
"ByVal" and see if it works.

Regards,
Kevin


"Sean" wrote in

message
...
Anyone know where I can find info on creating user

defined
excel fuctions?

Just as a rudimentary example:
---------------------
Public Function Test(ByVal dAmt As Double) As Double

Test = dAmt * 2

End Function
------------------
This returns the "#VALUE!" error message. Never done an
excel UDF, so I've no idea what I'm doing wrong (or even
right).

Thanks in advance,

Sean



.


Kevin Stecyk

User-Defined Excel Functions
 
Hi Sean

This works for me.

Option Explicit

Public Function Test(dAmt As Double) As Double

Test = dAmt * 2

End Function



In the spreadsheet, I entered in a cell, =Test(5)

The answer was 10.

So it works as planned.

If you have difficulty, I can send my sample spreadsheet.

Regards,
Kevin



"Sean" wrote in message
...
Thanks for the help, but it doesn't work either (I had
tried it byref, byval, with nothing).

I have tried boilerplate examples from MS, but they return
the same error.

Is there an option or setting I need to adjust? I can find
nothing under Tools--Options.
-----Original Message-----
Sean,

I think by definition a UDF has to be by reference. So I

would delete hte
"ByVal" and see if it works.

Regards,
Kevin


"Sean" wrote in

message
...
Anyone know where I can find info on creating user

defined
excel fuctions?

Just as a rudimentary example:
---------------------
Public Function Test(ByVal dAmt As Double) As Double

Test = dAmt * 2

End Function
------------------
This returns the "#VALUE!" error message. Never done an
excel UDF, so I've no idea what I'm doing wrong (or even
right).

Thanks in advance,

Sean



.




Sean[_7_]

User-Defined Excel Functions
 
GRRR!

I hate it when it turns out to be something silly.

I never put in "Option Explicit"

Thanks Kevin

-----Original Message-----
Hi Sean

This works for me.

Option Explicit

Public Function Test(dAmt As Double) As Double

Test = dAmt * 2

End Function



In the spreadsheet, I entered in a cell, =Test(5)

The answer was 10.

So it works as planned.

If you have difficulty, I can send my sample spreadsheet.

Regards,
Kevin



"Sean" wrote in

message
...
Thanks for the help, but it doesn't work either (I had
tried it byref, byval, with nothing).

I have tried boilerplate examples from MS, but they

return
the same error.

Is there an option or setting I need to adjust? I can

find
nothing under Tools--Options.
-----Original Message-----
Sean,

I think by definition a UDF has to be by reference.

So I
would delete hte
"ByVal" and see if it works.

Regards,
Kevin


"Sean" wrote in

message
...
Anyone know where I can find info on creating user

defined
excel fuctions?

Just as a rudimentary example:
---------------------
Public Function Test(ByVal dAmt As Double) As Double

Test = dAmt * 2

End Function
------------------
This returns the "#VALUE!" error message. Never done

an
excel UDF, so I've no idea what I'm doing wrong (or

even
right).

Thanks in advance,

Sean


.



.


Vasant Nanavati

User-Defined Excel Functions
 
Hi Sean:

While the use of Option Explicit is highly recommended, it should have had
no impact in this case, unless you misspelled a variable.

Regards,

Vasant.

"Sean" wrote in message
...
GRRR!

I hate it when it turns out to be something silly.

I never put in "Option Explicit"

Thanks Kevin

-----Original Message-----
Hi Sean

This works for me.

Option Explicit

Public Function Test(dAmt As Double) As Double

Test = dAmt * 2

End Function



In the spreadsheet, I entered in a cell, =Test(5)

The answer was 10.

So it works as planned.

If you have difficulty, I can send my sample spreadsheet.

Regards,
Kevin



"Sean" wrote in

message
...
Thanks for the help, but it doesn't work either (I had
tried it byref, byval, with nothing).

I have tried boilerplate examples from MS, but they

return
the same error.

Is there an option or setting I need to adjust? I can

find
nothing under Tools--Options.
-----Original Message-----
Sean,

I think by definition a UDF has to be by reference.

So I
would delete hte
"ByVal" and see if it works.

Regards,
Kevin


"Sean" wrote in
message
...
Anyone know where I can find info on creating user
defined
excel fuctions?

Just as a rudimentary example:
---------------------
Public Function Test(ByVal dAmt As Double) As Double

Test = dAmt * 2

End Function
------------------
This returns the "#VALUE!" error message. Never done

an
excel UDF, so I've no idea what I'm doing wrong (or

even
right).

Thanks in advance,

Sean


.



.




Tom Ogilvy

User-Defined Excel Functions
 
Putting it in a general module rather than a worksheet module would be
important. It worked fine in a general/standard module for me (without
using Option Explicit).

--
Regards,
Tom Ogilvy


"Sean" wrote in message
...
GRRR!

I hate it when it turns out to be something silly.

I never put in "Option Explicit"

Thanks Kevin

-----Original Message-----
Hi Sean

This works for me.

Option Explicit

Public Function Test(dAmt As Double) As Double

Test = dAmt * 2

End Function



In the spreadsheet, I entered in a cell, =Test(5)

The answer was 10.

So it works as planned.

If you have difficulty, I can send my sample spreadsheet.

Regards,
Kevin



"Sean" wrote in

message
...
Thanks for the help, but it doesn't work either (I had
tried it byref, byval, with nothing).

I have tried boilerplate examples from MS, but they

return
the same error.

Is there an option or setting I need to adjust? I can

find
nothing under Tools--Options.
-----Original Message-----
Sean,

I think by definition a UDF has to be by reference.

So I
would delete hte
"ByVal" and see if it works.

Regards,
Kevin


"Sean" wrote in
message
...
Anyone know where I can find info on creating user
defined
excel fuctions?

Just as a rudimentary example:
---------------------
Public Function Test(ByVal dAmt As Double) As Double

Test = dAmt * 2

End Function
------------------
This returns the "#VALUE!" error message. Never done

an
excel UDF, so I've no idea what I'm doing wrong (or

even
right).

Thanks in advance,

Sean


.



.





All times are GMT +1. The time now is 04:39 AM.

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