PDA

View Full Version : Solved: SQRT function and VBA : "sub or function not defined"



frade
10-24-2005, 04:48 AM
Hello,

Please have a look at my code VBA (sheet "Repeatability")
and especially the Public Sub REPEATABILITY()


I have a problem with this line

Sheets("TP_REPEAT").Range("D10") = 1.96 * SQRT((C10 * (1 - C10)) / (valA + valB))

compile error...sub or function not defined

What could I do?

Thank you

Bob Phillips
10-24-2005, 05:43 AM
Hello,

Please have a look at my code VBA (sheet "Repeatability")
and especially the Public Sub REPEATABILITY()


I have a problem with this line

Sheets("TP_REPEAT").Range("D10") = 1.96 * SQRT((C10 * (1 - C10)) / (valA + valB))

compile error...sub or function not defined

What could I do?

Thank you

Try Sqr not Sqrt.

frade
10-24-2005, 06:06 AM
Thank you xld..SQRT must be replaced by SQR :hi:


But, I have another one question..

The following formula give 0 as result...

valF = 1.96 * Sqr((valE * (1 - valE)) / valC)

Where is the problem?

Regards,

Fran?ois

Bob Phillips
10-24-2005, 06:11 AM
But, I have another one question..

The following formula give 0 as result...

valF = 1.96 * Sqr((valE * (1 - valE)) / valC)

Where is the problem?s

Probably because valE is greater than 1 and so the expresssion evaluates to a negative, which is a no-no for Sqr.

frade
10-24-2005, 06:19 AM
Ok, SQR is a function for positive values
but in my example, valE is well positive but less than 1

val E is equal to 0.4

Bob Phillips
10-24-2005, 06:29 AM
Ok, SQR is a function for positive values
but in my example, valE is well positive but less than 1

val E is equal to 0.4
This works for me


Dim ValE, ValF, ValC

ValE = 0.4
ValC = 12

ValF = 1.96 * Sqr((ValE * (1 - ValE)) / ValC)

frade
10-24-2005, 07:01 AM
Ok, thank you for your help. I have also tried to change the type of the variables.
(Long replaced by Double..and it's also OK!!)

Finally, I would like to modify (increase) automatically the column width (only for column B : 30.00 from the sheet "TP_repeat")

Bob Phillips
10-24-2005, 10:41 AM
Ok, thank you for your help. I have also tried to change the type of the variables.
(Long replaced by Double..and it's also OK!!)

Finally, I would like to modify (increase) automatically the column width (only for column B : 30.00 from the sheet "TP_repeat")

Worksheets("TP_repeat").Columns(2).ColumnWidth = 30

frade
10-25-2005, 02:46 AM
thanks a lot!