11 messages in org.openoffice.fr.progRe: Function utilisant comme variable...
FromSent OnAttachments
Rémi BApr 10, 2008 11:41 am 
Rémi BApr 10, 2008 2:41 pm 
Bernard MarcellyApr 11, 2008 2:49 am 
Rémi BApr 11, 2008 5:24 am 
Bernard MarcellyApr 11, 2008 6:32 am 
Francois GattoApr 11, 2008 7:18 am 
Francois GattoApr 11, 2008 7:37 am 
Bernard MarcellyApr 11, 2008 11:35 am 
Mathias MichelApr 11, 2008 4:45 pm 
Francois GattoApr 11, 2008 11:20 pm 
Rémi BApr 14, 2008 2:13 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Function utilisant comme variables de plages de cellulesActions...
From:Rémi B (rbou@free.fr)
Date:Apr 10, 2008 2:41:17 pm
List:org.openoffice.fr.prog

Re,

J'ai un peu avancé dans ma fonction de moyenne pondérée. Le problème demeure au niveau du type de variable... Si un cellule est vide, elle est interprétée comme contenant 0 (un absent a donc 0 !).

Il ne faut pas alors un type Variant, mais que mettre alors pour que "vide" soit bien "vide" et pas "0" ? Peut-être suis-je ne train de faire fausse route ?

Voici le code qui fonctionne bien en dehors de ce cas (toute critique bienvenue !) Function MoyPond(plage_coeff as Variant, plage_notes as Variant) as Variant total_notes_prod_coeff = 0 somme_coeff = 0 For i = Lbound(plage_coeff(),2) to UBound(plage_coeff(),2) if Not(IsEmpty(plage_notes(1,i))) Then If IsNumeric(plage_notes(1,i)) Then total_somme_prod_note_coeff = total_somme_prod_note_coeff + plage_coeff(1,i)*plage_notes(1,i) somme_coeffs = somme_coeffs + plage_coeff(1,i) End If End If next If somme_coeffs > 0 Then MoyPond = total_somme_prod_note_coeff/somme_coeffs Else MoyPond = "absent" End if End Function

la fonction est utilisée avec qqch de la forme : =MOYPOND(B2:D2;B3:D3)