ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I get this error: Sub or Function Not Defined (https://www.excelbanter.com/excel-programming/377430-i-get-error-sub-function-not-defined.html)

Debu

I get this error: Sub or Function Not Defined
 
I wrote a simple function in visual basic that uses Sqrt(), NormDist(), and
Power() functions. I can use these functions in any worksheet, but when I
include them in the Visual Basic function, it says "Sub or Function Not
Defined" for each of the above functions. However, it did not complain for
the Log() function though.

Help from Microsoft says that I should find WPS.EXE file, compile it from
some other computer, and then ... - totally over my head since I have no clue
what it is asking me to do. Wondering if you would have any simple and
reliable solution?

Regards,
Debu

Niek Otten

I get this error: Sub or Function Not Defined
 
HI Debu,

Check VBA's HELP for the syntax of the functions, like Sqr (not Sqrt).
There are more subtle differences.
You can often access the worksheet function version like with Application.Worksheetfunction.Sqrt , but even that is not always
true.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Debu" wrote in message ...
|I wrote a simple function in visual basic that uses Sqrt(), NormDist(), and
| Power() functions. I can use these functions in any worksheet, but when I
| include them in the Visual Basic function, it says "Sub or Function Not
| Defined" for each of the above functions. However, it did not complain for
| the Log() function though.
|
| Help from Microsoft says that I should find WPS.EXE file, compile it from
| some other computer, and then ... - totally over my head since I have no clue
| what it is asking me to do. Wondering if you would have any simple and
| reliable solution?
|
| Regards,
| Debu



Niek Otten

I get this error: Sub or Function Not Defined
 
I gave exactly the wrong example of calling a worksheetfunction. Try Application.worksheetfunction.Power

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Niek Otten" wrote in message ...
| HI Debu,
|
| Check VBA's HELP for the syntax of the functions, like Sqr (not Sqrt).
| There are more subtle differences.
| You can often access the worksheet function version like with Application.Worksheetfunction.Sqrt , but even that is not always
| true.
|
| --
| Kind regards,
|
| Niek Otten
| Microsoft MVP - Excel
|
|
| --
| Kind regards,
|
| Niek Otten
| Microsoft MVP - Excel
|
| "Debu" wrote in message ...
||I wrote a simple function in visual basic that uses Sqrt(), NormDist(), and
|| Power() functions. I can use these functions in any worksheet, but when I
|| include them in the Visual Basic function, it says "Sub or Function Not
|| Defined" for each of the above functions. However, it did not complain for
|| the Log() function though.
||
|| Help from Microsoft says that I should find WPS.EXE file, compile it from
|| some other computer, and then ... - totally over my head since I have no clue
|| what it is asking me to do. Wondering if you would have any simple and
|| reliable solution?
||
|| Regards,
|| Debu
|
|



Debu

I get this error: Sub or Function Not Defined
 
Apart from changing Sqrt to Sqr, I also included Application.WorkseetFunction
in front of the worksheet functions and it worked perfect!! Thank you Niek
for your response.

Best regards,
Debu

"Niek Otten" wrote:

HI Debu,

Check VBA's HELP for the syntax of the functions, like Sqr (not Sqrt).
There are more subtle differences.
You can often access the worksheet function version like with Application.Worksheetfunction.Sqrt , but even that is not always
true.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Debu" wrote in message ...
|I wrote a simple function in visual basic that uses Sqrt(), NormDist(), and
| Power() functions. I can use these functions in any worksheet, but when I
| include them in the Visual Basic function, it says "Sub or Function Not
| Defined" for each of the above functions. However, it did not complain for
| the Log() function though.
|
| Help from Microsoft says that I should find WPS.EXE file, compile it from
| some other computer, and then ... - totally over my head since I have no clue
| what it is asking me to do. Wondering if you would have any simple and
| reliable solution?
|
| Regards,
| Debu




Debu

I get this error: Sub or Function Not Defined
 
Sorry, I forgot to mention that I did use Power in place of Sqrt (or Sqr)
function. Regards, Debu

"Debu" wrote:

Apart from changing Sqrt to Sqr, I also included Application.WorkseetFunction
in front of the worksheet functions and it worked perfect!! Thank you Niek
for your response.

Best regards,
Debu

"Niek Otten" wrote:

HI Debu,

Check VBA's HELP for the syntax of the functions, like Sqr (not Sqrt).
There are more subtle differences.
You can often access the worksheet function version like with Application.Worksheetfunction.Sqrt , but even that is not always
true.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Debu" wrote in message ...
|I wrote a simple function in visual basic that uses Sqrt(), NormDist(), and
| Power() functions. I can use these functions in any worksheet, but when I
| include them in the Visual Basic function, it says "Sub or Function Not
| Defined" for each of the above functions. However, it did not complain for
| the Log() function though.
|
| Help from Microsoft says that I should find WPS.EXE file, compile it from
| some other computer, and then ... - totally over my head since I have no clue
| what it is asking me to do. Wondering if you would have any simple and
| reliable solution?
|
| Regards,
| Debu




Tom Ogilvy

I get this error: Sub or Function Not Defined
 
VBA does not support use of the worksheet function.

VBA has its own square root function names Sqr

this requires no qualification with application or worksheetfunction or
application.worksheetfunction because it is a built in VBA function. You can
see what built in Excel functions are supported for use in VBA (with the
qualification) by looking in the object browser in the VBE and finding the
worksheetfuction object.

--
Regards,
Tom Ogilvy

"Debu" wrote:

Sorry, I forgot to mention that I did use Power in place of Sqrt (or Sqr)
function. Regards, Debu

"Debu" wrote:

Apart from changing Sqrt to Sqr, I also included Application.WorkseetFunction
in front of the worksheet functions and it worked perfect!! Thank you Niek
for your response.

Best regards,
Debu

"Niek Otten" wrote:

HI Debu,

Check VBA's HELP for the syntax of the functions, like Sqr (not Sqrt).
There are more subtle differences.
You can often access the worksheet function version like with Application.Worksheetfunction.Sqrt , but even that is not always
true.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Debu" wrote in message ...
|I wrote a simple function in visual basic that uses Sqrt(), NormDist(), and
| Power() functions. I can use these functions in any worksheet, but when I
| include them in the Visual Basic function, it says "Sub or Function Not
| Defined" for each of the above functions. However, it did not complain for
| the Log() function though.
|
| Help from Microsoft says that I should find WPS.EXE file, compile it from
| some other computer, and then ... - totally over my head since I have no clue
| what it is asking me to do. Wondering if you would have any simple and
| reliable solution?
|
| Regards,
| Debu




Debu

I get this error: Sub or Function Not Defined
 
Thanks Tom, the list of these functions requiring no qualification is
certainly helpful and reduces some coding effort. Regards, Debu

"Tom Ogilvy" wrote:

VBA does not support use of the worksheet function.

VBA has its own square root function names Sqr

this requires no qualification with application or worksheetfunction or
application.worksheetfunction because it is a built in VBA function. You can
see what built in Excel functions are supported for use in VBA (with the
qualification) by looking in the object browser in the VBE and finding the
worksheetfuction object.

--
Regards,
Tom Ogilvy

"Debu" wrote:

Sorry, I forgot to mention that I did use Power in place of Sqrt (or Sqr)
function. Regards, Debu

"Debu" wrote:

Apart from changing Sqrt to Sqr, I also included Application.WorkseetFunction
in front of the worksheet functions and it worked perfect!! Thank you Niek
for your response.

Best regards,
Debu

"Niek Otten" wrote:

HI Debu,

Check VBA's HELP for the syntax of the functions, like Sqr (not Sqrt).
There are more subtle differences.
You can often access the worksheet function version like with Application.Worksheetfunction.Sqrt , but even that is not always
true.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Debu" wrote in message ...
|I wrote a simple function in visual basic that uses Sqrt(), NormDist(), and
| Power() functions. I can use these functions in any worksheet, but when I
| include them in the Visual Basic function, it says "Sub or Function Not
| Defined" for each of the above functions. However, it did not complain for
| the Log() function though.
|
| Help from Microsoft says that I should find WPS.EXE file, compile it from
| some other computer, and then ... - totally over my head since I have no clue
| what it is asking me to do. Wondering if you would have any simple and
| reliable solution?
|
| Regards,
| Debu




ultima

I get this error: Sub or Function Not Defined
 

--
ultima


"Debu" wrote:

I wrote a simple function in visual basic that uses Sqrt(), NormDist(), and
Power() functions. I can use these functions in any worksheet, but when I
include them in the Visual Basic function, it says "Sub or Function Not
Defined" for each of the above functions. However, it did not complain for
the Log() function though.

Help from Microsoft says that I should find WPS.EXE file, compile it from
some other computer, and then ... - totally over my head since I have no clue
what it is asking me to do. Wondering if you would have any simple and
reliable solution?

Regards,
Debu


ultima

I get this error: Sub or Function Not Defined
 
I am trying to use the worksheet functions xirr and xnpv but get the same
error message as Debu. The syntax I am using is
Application.WorksheetFunction.XIRR(arguments). Both xirr and xnpv are listed
in the objects browser. What am I doing wrong?
--
ultima


"Debu" wrote:

I wrote a simple function in visual basic that uses Sqrt(), NormDist(), and
Power() functions. I can use these functions in any worksheet, but when I
include them in the Visual Basic function, it says "Sub or Function Not
Defined" for each of the above functions. However, it did not complain for
the Log() function though.

Help from Microsoft says that I should find WPS.EXE file, compile it from
some other computer, and then ... - totally over my head since I have no clue
what it is asking me to do. Wondering if you would have any simple and
reliable solution?

Regards,
Debu


ultima

I get this error: Sub or Function Not Defined
 
I also get the error message: "Run-time error 1004, Unable to get the
property of the WorksheetFunction class". Any have a clue about what this
means and how to fix the problem?
--
ultima


"Debu" wrote:

I wrote a simple function in visual basic that uses Sqrt(), NormDist(), and
Power() functions. I can use these functions in any worksheet, but when I
include them in the Visual Basic function, it says "Sub or Function Not
Defined" for each of the above functions. However, it did not complain for
the Log() function though.

Help from Microsoft says that I should find WPS.EXE file, compile it from
some other computer, and then ... - totally over my head since I have no clue
what it is asking me to do. Wondering if you would have any simple and
reliable solution?

Regards,
Debu



All times are GMT +1. The time now is 12:31 PM.

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