Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
average of values 0
Is there a way to make the average funtion work in vba so that it selects only values 0 in a given range? Something like avv = Application.WorksheetFunction.Average(if(Range("'d ata'!" & srt) 0)) =average(if(b2.b5000)) works in excel and I'd like the equivqlent in vba if possible Thanks Chris |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
average of values 0
Hi Chris,
you can use this: =worksheetfunction.SumIf(selection,"0",selection)/worksheetfunction.CountIf(selection,"0") replace selection with range you wish regards, Ivan |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
average of values 0
how about something like this?
Range("a1").Value = WorksheetFunction.Sum(Range("b2:b500")) / _ WorksheetFunction.CountIf(Range("b2:b500"), "0") -- Gary "inquirer" wrote in message ... Is there a way to make the average funtion work in vba so that it selects only values 0 in a given range? Something like avv = Application.WorksheetFunction.Average(if(Range("'d ata'!" & srt) 0)) =average(if(b2.b5000)) works in excel and I'd like the equivqlent in vba if possible Thanks Chris |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
average of values 0
or this
Range("a1").FormulaArray = "=average(if(b2:b5000,b2:b500))" -- Gary "inquirer" wrote in message ... Is there a way to make the average funtion work in vba so that it selects only values 0 in a given range? Something like avv = Application.WorksheetFunction.Average(if(Range("'d ata'!" & srt) 0)) =average(if(b2.b5000)) works in excel and I'd like the equivqlent in vba if possible Thanks Chris |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
average of values 0
or even
Range("a1").Value = Evaluate("=average(if(b2:b5000,b2:b500))") -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... or this Range("a1").FormulaArray = "=average(if(b2:b5000,b2:b500))" -- Gary "inquirer" wrote in message ... Is there a way to make the average funtion work in vba so that it selects only values 0 in a given range? Something like avv = Application.WorksheetFunction.Average(if(Range("'d ata'!" & srt) 0)) =average(if(b2.b5000)) works in excel and I'd like the equivqlent in vba if possible Thanks Chris |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
average of values 0
inquirer wrote:
Is there a way to make the average funtion work in vba so that it selects only values 0 in a given range? Something like avv = Application.WorksheetFunction.Average(if(Range("'d ata'!" & srt) 0)) =average(if(b2.b5000)) works in excel and I'd like the equivqlent in vba if possible Thanks Chris I guess I didn't make myself clear... what I was looking for two things: how to put a named range into the worksheet function (the way I was doing it doesn't seem to work), and how to use a conditional statement in the function. Ivan's solution is fine for getting averages but what about other functions like stdev and var? Thanks Chris |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
A formula to AVERAGE IF but only average a set number of values | Excel Worksheet Functions | |||
average values in non-contiguous cells, ignoring 0 values | Excel Worksheet Functions | |||
Average non zero values | Excel Worksheet Functions | |||
Average AM or PM values | Excel Discussion (Misc queries) | |||
Error Handling #N/A with AVERAGE Function - Average of values in Row | Excel Worksheet Functions |