ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calculate Median with a macro (https://www.excelbanter.com/excel-programming/321516-calculate-median-macro.html)

K McCurry[_2_]

Calculate Median with a macro
 
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.

Tom Ogilvy

Calculate Median with a macro
 
Application.Median(Range("C1:J100"))

--
Regards,
Tom Ogilvy

"K McCurry" wrote in message
...
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.




K McCurry[_2_]

Calculate Median with a macro
 
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.


"Tom Ogilvy" wrote:

Application.Median(Range("C1:J100"))

--
Regards,
Tom Ogilvy

"K McCurry" wrote in message
...
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.





Tom Ogilvy

Calculate Median with a macro
 
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

--
Regards,
Tom Ogilvy

"K McCurry" wrote in message
...
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.


"Tom Ogilvy" wrote:

Application.Median(Range("C1:J100"))

--
Regards,
Tom Ogilvy

"K McCurry" wrote in message
...
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.







K McCurry[_2_]

Calculate Median with a macro
 
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.

"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy

"K McCurry" wrote in message
...
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.


"Tom Ogilvy" wrote:

Application.Median(Range("C1:J100"))

--
Regards,
Tom Ogilvy

"K McCurry" wrote in message
...
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.








All times are GMT +1. The time now is 10:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com