View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default How to automate the calculation of the median from a frq distribut

Hi Alaska

I think this would work if you placed your array in column A. It uses the
formula (n+1) /2 as the estimator for the median

Dim datarange As Range


Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Dim datarange As Range

Set datarange = Selection

k = datarange.Rows.Count + 1
k = k / 2

Range("a1").Select
For x = 1 To k
ActiveCell.Offset(1, 0).Select
Next

MsgBox (" THE MEDIAN IS ") & ActiveCell.Value


Hope this helps

Best N10



"Alaska Hydro" wrote in message
...
Instructions for calculating the median froma frequency distribution tend
to
rely on a visual interpretation of the frequency distribution. I have
hundreds of frequency distributions that I want to calculate the median
for.

Can I automate the calculation of the median directly using code or do I
need to transform the distribution temporarily into its original array
then
calc?

I can provide examples if necessary.
thanks.