Hello ,
I calculated the median with multiple criteria, the calculation is slow I wanted to make it with vba because calculation could be faster.
The exercise which I linked it is just an example. The slow execution is on my real file which contains 11 offers and more than 3 thousands lines.
The formula for the calculation:
IFERROR(MEDIAN(IF(($A$2:$A$44=$N$1)*($E$2:$E$44=J$2)*($B$2:$B$44=$I3)*($F$2:$F$44=$M$1);$G$2:$G$44));"")
validate with Ctrl + shift + enter
I tried this VBA code but it does not work
Sub MEDIAN()
For Each cell In Range("J3:L9")
year = Range("m1")
offer = UCase(Range("n1"))
month = UCase(Cells(2, cell.Column))
day = UCase(Cells(cell.Row,9))
cell.Value = Application.Evaluate("MEDIAN(IF((" & _
offer & "=R1C14)*(" & _
day & "=RC9)," & _
month & "R2C)," & _
year & "=R1C13)," & _
C7 & "))")
Next cell
End Sub
the link is : https://onedrive.live.com/redir?resi...nt=file%2cxlsx
Thanks for helping me
Bookmarks