#1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 8
Default Coding

What would be the code in a macro to accomplish the following:


If the (maximum of cell range A5 thru A9) is greater than the
(average of cells A5 thru A9) times 1.05 or if the (minimum of cell
range A5 thru A9) is less than the (average of cell A5 thru A9) times
0.95 then A10 equals "Fail" else A10 = "Pass"


Some time back I got information on a similar problem, but I had a
computer crash and I lost it.

Any help would be appreciated.


Ed English
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Coding

Hi,

If I've iunderstood correctly, try this

Dim MyRange As Range
Set MyRange = Range("A5:A9")
If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _
WorksheetFunction.Min(MyRange) < WorksheetFunction.Average(MyRange) * 0.05
Then
Range("A10").Value = "Fail"
Else
Range("A10").Value = "Pass"
End If

Mike

"Ed" wrote:

What would be the code in a macro to accomplish the following:


If the (maximum of cell range A5 thru A9) is greater than the
(average of cells A5 thru A9) times 1.05 or if the (minimum of cell
range A5 thru A9) is less than the (average of cell A5 thru A9) times
0.95 then A10 equals "Fail" else A10 = "Pass"


Some time back I got information on a similar problem, but I had a
computer crash and I lost it.

Any help would be appreciated.


Ed English

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Coding

Typo,

Try this instead

Dim MyRange As Range
Set MyRange = Range("A5:A9")
If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _
WorksheetFunction.Min(MyRange) < WorksheetFunction.Average(MyRange) * 0.95
Then
Range("A10").Value = "Fail"
Else
Range("A10").Value = "Pass"
End If

Mike

"Mike H" wrote:

Hi,

If I've iunderstood correctly, try this

Dim MyRange As Range
Set MyRange = Range("A5:A9")
If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _
WorksheetFunction.Min(MyRange) < WorksheetFunction.Average(MyRange) * 0.05
Then
Range("A10").Value = "Fail"
Else
Range("A10").Value = "Pass"
End If

Mike

"Ed" wrote:

What would be the code in a macro to accomplish the following:


If the (maximum of cell range A5 thru A9) is greater than the
(average of cells A5 thru A9) times 1.05 or if the (minimum of cell
range A5 thru A9) is less than the (average of cell A5 thru A9) times
0.95 then A10 equals "Fail" else A10 = "Pass"


Some time back I got information on a similar problem, but I had a
computer crash and I lost it.

Any help would be appreciated.


Ed English

  #4   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 8
Default Coding

Mike,

Tried both and got compile error. will review and advise.

Thanks for replies.


Ed English


On Tue, 12 May 2009 03:35:03 -0700, Mike H
wrote:

Hi,

If I've iunderstood correctly, try this

Dim MyRange As Range
Set MyRange = Range("A5:A9")
If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _
WorksheetFunction.Min(MyRange) < WorksheetFunction.Average(MyRange) * 0.05
Then
Range("A10").Value = "Fail"
Else
Range("A10").Value = "Pass"
End If

Mike

"Ed" wrote:

What would be the code in a macro to accomplish the following:


If the (maximum of cell range A5 thru A9) is greater than the
(average of cells A5 thru A9) times 1.05 or if the (minimum of cell
range A5 thru A9) is less than the (average of cell A5 thru A9) times
0.95 then A10 equals "Fail" else A10 = "Pass"


Some time back I got information on a similar problem, but I had a
computer crash and I lost it.

Any help would be appreciated.


Ed English

  #5   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 8
Default Coding

It is a syntax error


On Tue, 12 May 2009 03:38:01 -0700, Mike H
wrote:

Typo,

Try this instead

Dim MyRange As Range
Set MyRange = Range("A5:A9")
If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _
WorksheetFunction.Min(MyRange) < WorksheetFunction.Average(MyRange) * 0.95
Then
Range("A10").Value = "Fail"
Else
Range("A10").Value = "Pass"
End If

Mike

"Mike H" wrote:

Hi,

If I've iunderstood correctly, try this

Dim MyRange As Range
Set MyRange = Range("A5:A9")
If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _
WorksheetFunction.Min(MyRange) < WorksheetFunction.Average(MyRange) * 0.05
Then
Range("A10").Value = "Fail"
Else
Range("A10").Value = "Pass"
End If

Mike

"Ed" wrote:

What would be the code in a macro to accomplish the following:


If the (maximum of cell range A5 thru A9) is greater than the
(average of cells A5 thru A9) times 1.05 or if the (minimum of cell
range A5 thru A9) is less than the (average of cell A5 thru A9) times
0.95 then A10 equals "Fail" else A10 = "Pass"


Some time back I got information on a similar problem, but I had a
computer crash and I lost it.

Any help would be appreciated.


Ed English



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Coding

Ed,

The syntax error is caused by the post line-wrapping.

This is all one line

If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _

Mike

"Ed" wrote:

It is a syntax error


On Tue, 12 May 2009 03:38:01 -0700, Mike H
wrote:

Typo,

Try this instead

Dim MyRange As Range
Set MyRange = Range("A5:A9")
If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _
WorksheetFunction.Min(MyRange) < WorksheetFunction.Average(MyRange) * 0.95
Then
Range("A10").Value = "Fail"
Else
Range("A10").Value = "Pass"
End If

Mike

"Mike H" wrote:

Hi,

If I've iunderstood correctly, try this

Dim MyRange As Range
Set MyRange = Range("A5:A9")
If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _
WorksheetFunction.Min(MyRange) < WorksheetFunction.Average(MyRange) * 0.05
Then
Range("A10").Value = "Fail"
Else
Range("A10").Value = "Pass"
End If

Mike

"Ed" wrote:

What would be the code in a macro to accomplish the following:


If the (maximum of cell range A5 thru A9) is greater than the
(average of cells A5 thru A9) times 1.05 or if the (minimum of cell
range A5 thru A9) is less than the (average of cell A5 thru A9) times
0.95 then A10 equals "Fail" else A10 = "Pass"


Some time back I got information on a similar problem, but I had a
computer crash and I lost it.

Any help would be appreciated.


Ed English


  #7   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 8
Default Coding

Mike,

I did get it to run. Thanks for your help.


Ed English



On Tue, 12 May 2009 09:34:07 -0700, Mike H
wrote:

Ed,

The syntax error is caused by the post line-wrapping.

This is all one line

If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _

Mike

"Ed" wrote:

It is a syntax error


On Tue, 12 May 2009 03:38:01 -0700, Mike H
wrote:

Typo,

Try this instead

Dim MyRange As Range
Set MyRange = Range("A5:A9")
If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _
WorksheetFunction.Min(MyRange) < WorksheetFunction.Average(MyRange) * 0.95
Then
Range("A10").Value = "Fail"
Else
Range("A10").Value = "Pass"
End If

Mike

"Mike H" wrote:

Hi,

If I've iunderstood correctly, try this

Dim MyRange As Range
Set MyRange = Range("A5:A9")
If WorksheetFunction.Max(MyRange) WorksheetFunction.Average(MyRange) *
1.05 Or _
WorksheetFunction.Min(MyRange) < WorksheetFunction.Average(MyRange) * 0.05
Then
Range("A10").Value = "Fail"
Else
Range("A10").Value = "Pass"
End If

Mike

"Ed" wrote:

What would be the code in a macro to accomplish the following:


If the (maximum of cell range A5 thru A9) is greater than the
(average of cells A5 thru A9) times 1.05 or if the (minimum of cell
range A5 thru A9) is less than the (average of cell A5 thru A9) times
0.95 then A10 equals "Fail" else A10 = "Pass"


Some time back I got information on a similar problem, but I had a
computer crash and I lost it.

Any help would be appreciated.


Ed English


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with coding anna New Users to Excel 4 April 24th 08 05:06 AM
coding vba paul[_17_] Excel Programming 9 August 17th 07 05:56 PM
Coding metaltecks Excel Discussion (Misc queries) 1 April 17th 06 10:12 PM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM


All times are GMT +1. The time now is 01:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"