Mediane avec multiconditions

serir

New Member
Joined
Feb 21, 2016
Messages
3
Bonjour tous :cool:,

J'ai calculé la médiane avec multi-conditions, le calcul est lent je voulais le faire avec le vba puisque le calcule pourrait être plus rapide.

L'exercice que j'ai joint c'est juste un exemple. L’exécution lente est sur mon vrai fichier qui contient plusieurs offres et un nombre important de lignes.

J'ai essayé ce code mais ça ne marche pas

Sub MEDIANE()
For Each cellule In Range("M3:X9")
annee = Range("x1")
offre = UCase(Range("y1"))
mois = UCase(Cells(2, cellule.Column))
jour = UCase(Cells(cellule.Row, 11))
cellule.Value = Application.Evaluate("MEDIAN(IF((" & _
offre & "=R1C25)*(" & _
jour & "=RC11)," & _
mois & "R2C)," & _
annee & "=R1C24)," & _
C8 & "))")
Next cellule
End Sub

Le fichier est sur le lien : https://onedrive.live.com/redir?resid=8952CE5DAEF23B26!122&authkey=!AK_xvd_-saszoGs&ithint=file,xlsx

Merci pour votre aide.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Salutations Serir,

Pour une réponse rapide et appropriée, s'il vous plaît poster votre demande dans les "questions dans d'autres langues" forum.

Merci,
vcoolio.
 
Upvote 0
Désolé le code est :

[TABLE="width: 92"]
<colgroup><col></colgroup><tbody>[TR]
[TD]Sub MEDIANE()[/TD]
[/TR]
[TR]
[TD]For Each cellule In Range("J3:L9")[/TD]
[/TR]
[TR]
[TD]annee = Range("m1")[/TD]
[/TR]
[TR]
[TD]offre = UCase(Range("n1"))[/TD]
[/TR]
[TR]
[TD]mois = UCase(Cells(2, cellule.Column))[/TD]
[/TR]
[TR]
[TD]jour = UCase(Cells(cellule.Row,9))[/TD]
[/TR]
[TR]
[TD]cellule.Value = Application.Evaluate("MEDIAN(IF((" & _[/TD]
[/TR]
[TR]
[TD]offre & "=R1C14)*(" & _[/TD]
[/TR]
[TR]
[TD]jour & "=RC9)," & _[/TD]
[/TR]
[TR]
[TD]mois & "R2C)," & _[/TD]
[/TR]
[TR]
[TD]annee & "=R1C13)," & _[/TD]
[/TR]
[TR]
[TD]C7 & "))")[/TD]
[/TR]
[TR]
[TD]Next cellule[/TD]
[/TR]
[TR]
[TD]End Sub[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 92"]
<colgroup><col></colgroup><tbody>[TR]
[TD]Sub MEDIANE()[/TD]
[/TR]
[TR]
[TD]For Each cellule In Range("J3:L9")[/TD]
[/TR]
[TR]
[TD]annee = Range("m1")[/TD]
[/TR]
[TR]
[TD]offre = UCase(Range("n1"))[/TD]
[/TR]
[TR]
[TD]mois = UCase(Cells(2, cellule.Column))[/TD]
[/TR]
[TR]
[TD]jour = UCase(Cells(cellule.Row,9))[/TD]
[/TR]
[TR]
[TD]cellule.Value = Application.Evaluate("MEDIAN(IF((" & _[/TD]
[/TR]
[TR]
[TD]offre & "=R1C14)*(" & _[/TD]
[/TR]
[TR]
[TD]jour & "=RC9)," & _[/TD]
[/TR]
[TR]
[TD]mois & "R2C)," & _[/TD]
[/TR]
[TR]
[TD]annee & "=R1C13)," & _[/TD]
[/TR]
[TR]
[TD]C7 & "))")[/TD]
[/TR]
[TR]
[TD]Next cellule[/TD]
[/TR]
[TR]
[TD]End Sub[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,937
Messages
6,175,522
Members
452,650
Latest member
Tinfish

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top