Calculate Median with a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I set up a macro to calulate Medain? The median will be in in its own
column which is col K and the data will be cols c through J. Also the data
could be off any size (could many records). Thanks.
 
Thanks for responding. How would use that command to calulate the median if
you did not know how many records would be in the file? The median will be
in column M and the range I am using will be C - K. I would like to run a
macro for this. Thanks.
 
do you mean you want the meadian for the values in each row in columns C to
K, then entered in the corresponding cell in column M?

Sub ComputeMedian()
set rng = Range(cells(2,3),cells(rows.count,3).End(xlup)
for each cell in rng
cell.offset(0,10) = application.Median(cell.resize(1,9))
Next
End Sub
 
Yes that would be correct. It would need to calculate the median for each
row in column M. I will give what you sent a try. Hope that helps. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top