Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Please advise how to correct syntax error in the following:
if min(a5:a9)< avg(a5:a9)*0.95 and if max(a5:a9) avg(a5:a9)* 1.05 then a13 = "fail" else a13 = "pass" Thank you |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
As a worksheet formula in cell a13 =if (and(min("a5:a9")< average("a5:a9")*0.95 , max("a5:a9") average ("a5:a9")*1.05) , "fail" , "pass") As VBA if min(Range("a5:a9"))< worksheetfunctions.average(Range("a5:a9")) *0.95 and max(Range("a5:a9")) worksheetfunctions.average(Range ("a5:a9"))* 1.05 then Range("a13").value = "fail" else Range("a13").value = "pass" the VBA should all be on one line regards Paul On Mar 31, 3:08*pm, Ed wrote: Please advise how to correct syntax error in the following: if min(a5:a9)< avg(a5:a9)*0.95 and if max(a5:a9) avg(a5:a9)* 1.05 then a13 = *"fail" else a13 = "pass" Thank you |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Paul's suggestions
When I insert the worksheet formula I get "#value", although there appears that I'm working only with numbers. When I try to run the VBA all on one line I get the Compile error - "sub or function not defined". --------------------------------------------------------------------- Rick's suggestions When I try to run his suggestion I get the message: Unable to get the minimum property of the worksheet function class. class ----------------------------------------------------------------------------- On Tue, 31 Mar 2009 07:39:25 -0700 (PDT), wrote: Hi As a worksheet formula in cell a13 =if (and(min("a5:a9")< average("a5:a9")*0.95 , max("a5:a9") average ("a5:a9")*1.05) , "fail" , "pass") As VBA if min(Range("a5:a9"))< worksheetfunctions.average(Range("a5:a9")) *0.95 and max(Range("a5:a9")) worksheetfunctions.average(Range ("a5:a9"))* 1.05 then Range("a13").value = "fail" else Range("a13").value = "pass" the VBA should all be on one line regards Paul On Mar 31, 3:08*pm, Ed wrote: Please advise how to correct syntax error in the following: if min(a5:a9)< avg(a5:a9)*0.95 and if max(a5:a9) avg(a5:a9)* 1.05 then a13 = *"fail" else a13 = "pass" Thank you |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The worksheet formula appoach is interesting.
How could the "#VALUE " result be corrected? On Tue, 31 Mar 2009 07:39:25 -0700 (PDT), wrote: Hi As a worksheet formula in cell a13 =if (and(min("a5:a9")< average("a5:a9")*0.95 , max("a5:a9") average ("a5:a9")*1.05) , "fail" , "pass") As VBA if min(Range("a5:a9"))< worksheetfunctions.average(Range("a5:a9")) *0.95 and max(Range("a5:a9")) worksheetfunctions.average(Range ("a5:a9"))* 1.05 then Range("a13").value = "fail" else Range("a13").value = "pass" the VBA should all be on one line regards Paul On Mar 31, 3:08*pm, Ed wrote: Please advise how to correct syntax error in the following: if min(a5:a9)< avg(a5:a9)*0.95 and if max(a5:a9) avg(a5:a9)* 1.05 then a13 = *"fail" else a13 = "pass" Thank you |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Sorry -you don't want the quotes "" in the formula. regards Paul On Mar 31, 9:59*pm, Ed wrote: The worksheet formula appoach is interesting. How could the "#VALUE " result be corrected? On Tue, 31 Mar 2009 07:39:25 -0700 (PDT), wrote: Hi As a worksheet formula in cell a13 =if (and(min("a5:a9")< average("a5:a9")*0.95 , max("a5:a9") average ("a5:a9")*1.05) , "fail" , "pass") As VBA if min(Range("a5:a9"))< worksheetfunctions.average(Range("a5:a9")) *0.95 and max(Range("a5:a9")) worksheetfunctions.average(Range ("a5:a9"))* 1.05 then Range("a13").value = *"fail" else Range("a13").value *= "pass" the VBA should all be on one line regards Paul On Mar 31, 3:08*pm, Ed wrote: Please advise how to correct syntax error in the following: if min(a5:a9)< avg(a5:a9)*0.95 and if max(a5:a9) avg(a5:a9)* 1.05 then a13 = *"fail" else a13 = "pass" Thank you |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the lead. Your worksheet formula works if the quotes are
reoved from the min, max, and avg values. Thanks again, Ed English On Tue, 31 Mar 2009 07:39:25 -0700 (PDT), wrote: Hi As a worksheet formula in cell a13 =if (and(min("a5:a9")< average("a5:a9")*0.95 , max("a5:a9") average ("a5:a9")*1.05) , "fail" , "pass") As VBA if min(Range("a5:a9"))< worksheetfunctions.average(Range("a5:a9")) *0.95 and max(Range("a5:a9")) worksheetfunctions.average(Range ("a5:a9"))* 1.05 then Range("a13").value = "fail" else Range("a13").value = "pass" the VBA should all be on one line regards Paul On Mar 31, 3:08*pm, Ed wrote: Please advise how to correct syntax error in the following: if min(a5:a9)< avg(a5:a9)*0.95 and if max(a5:a9) avg(a5:a9)* 1.05 then a13 = *"fail" else a13 = "pass" Thank you |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
See if this does what you want...
With WorksheetFunction If (.Min("a5:a9") < .Average("a5:a9") * 0.95) And _ (.Max("a5:a9") .Average("a5:a9") * 1.05) Then a13 = "fail" Else a13 = "pass" End If End With -- Rick (MVP - Excel) "Ed" wrote in message ... Please advise how to correct syntax error in the following: if min(a5:a9)< avg(a5:a9)*0.95 and if max(a5:a9) avg(a5:a9)* 1.05 then a13 = "fail" else a13 = "pass" Thank you |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Paul's suggestions
When I insert the worksheet formula I get "#value", although there appears that I'm working only with numbers. When I try to run the VBA all on one line I get the Compile error - "sub or function not defined". --------------------------------------------------------------------- Rick's suggestions When I try to run his suggestion I get the message: Unable to get the minimum property of the worksheet function class. class On Tue, 31 Mar 2009 10:43:49 -0400, "Rick Rothstein" wrote: See if this does what you want... With WorksheetFunction If (.Min("a5:a9") < .Average("a5:a9") * 0.95) And _ (.Max("a5:a9") .Average("a5:a9") * 1.05) Then a13 = "fail" Else a13 = "pass" End If End With |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, I forgot the "Range" part...
With Application.WorksheetFunction If (.Min(Range("A5:A9")) < .Average(Range("A5:A9")) * 0.95) And _ (.Max(Range("A5:A9")) .Average(Range("A5:A9")) * 1.05) Then a13 = "fail" Else a13 = "pass" End If End With -- Rick (MVP - Excel) "Ed" wrote in message ... Paul's suggestions When I insert the worksheet formula I get "#value", although there appears that I'm working only with numbers. When I try to run the VBA all on one line I get the Compile error - "sub or function not defined". --------------------------------------------------------------------- Rick's suggestions When I try to run his suggestion I get the message: Unable to get the minimum property of the worksheet function class. class On Tue, 31 Mar 2009 10:43:49 -0400, "Rick Rothstein" wrote: See if this does what you want... With WorksheetFunction If (.Min("a5:a9") < .Average("a5:a9") * 0.95) And _ (.Max("a5:a9") .Average("a5:a9") * 1.05) Then a13 = "fail" Else a13 = "pass" End If End With |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Ran revised code with no error message. Based on numbers in file result would be "pass", but no result at all is showing in A13. "and" in code should be "or". On Tue, 31 Mar 2009 14:34:01 -0400, "Rick Rothstein" wrote: Sorry, I forgot the "Range" part... With Application.WorksheetFunction If (.Min(Range("A5:A9")) < .Average(Range("A5:A9")) * 0.95) And _ (.Max(Range("A5:A9")) .Average(Range("A5:A9")) * 1.05) Then a13 = "fail" Else a13 = "pass" End If End With |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is A13 the name of a variable? Or is it a cell address? If a cell address,
then the assignment lines should look like this... Range("A13").Value = "fail" and similar for the "pass" assignment line also. As for "and" versus "or"... I just used the logical operator you showed in your original posting (only you know what kind of test you are performing and what the results of that test mean). -- Rick (MVP - Excel) "Ed" wrote in message ... Ran revised code with no error message. Based on numbers in file result would be "pass", but no result at all is showing in A13. "and" in code should be "or". On Tue, 31 Mar 2009 14:34:01 -0400, "Rick Rothstein" wrote: Sorry, I forgot the "Range" part... With Application.WorksheetFunction If (.Min(Range("A5:A9")) < .Average(Range("A5:A9")) * 0.95) And _ (.Max(Range("A5:A9")) .Average(Range("A5:A9")) * 1.05) Then a13 = "fail" Else a13 = "pass" End If End With |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Syntax | Excel Programming | |||
Run Time errot 1004, with formula | Excel Programming | |||
If then syntax | Excel Worksheet Functions | |||
SQL syntax | Excel Programming | |||
errot in macro | Excel Discussion (Misc queries) |