Average of unbound cells?

C90RanMan

New member
Local time
Today, 04:38
Joined
Jul 29, 2010
Messages
7
I am trying to Average values in four unbound cells(named: Dif1, Dif2, Dif3 and Dif4) on a form. Some cells will have zero values so I only want to average the cells that have a value greater than zero. Any guidence would be appreciated.

Best Regards
 
dim intCount as integer
dim h as integer
dim lngtotal as long
dim lngAverage as long

intCount=0

for h= 1 to 4
if me.controls("Diff" & h).value<>0 then
lngtotal=lngtotal+me.controls("Diff" & h).value
intcount=intcount+1
end if
next h

lngAverage = lngtotal/intCount
 

Users who are viewing this thread

Back
Top Bottom