# Easy Range question

#### hayden

##### Board Regular
Hello everyone. I got stuck again. Did a quick search and couldn't find anything on this so here it is.

I am trying to get the median of a series of numbers.

In column 3, row 49 i start a list of daily flows. I am trying to calculate a medain flow for the month, this means my range is 31 days the first month, then 29 (leap year) then 31 etc. I would like the medain values for each month to be displayed in column 4, starting in row 49.

Here is the code I have so far.

Code:
``````Sub monthlymedian()
Dim d As Integer

For i = 1 To 36
d = Cells(i, 12).Value
Cells(i + 48, 5).Select
ActiveCell.FormulaR1C1 = "=MEDIAN(RC[-2]:R[" & d - 1 & "]C[-2])"
' Worksheet.Function.Median (Range("d" & j & ":d" & j + d - 1))
Next
End Sub``````

the integer d is the number of days each month and they are located in column 12, row 1 - 36 (i have 3 years of data).

I am stuck on the activecell.formula line. Cany anyone help here?

Thanks again

hayden

### Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Request for some clarifications
Assume i=1
and
d=30
then
I think according to your code, the activecell is E49
Then what is the range for which median is required in A1 styl.e?

Replies
7
Views
232
Replies
8
Views
174
Replies
3
Views
273
Replies
7
Views
463
Replies
8
Views
539

1,221,240
Messages
6,158,724
Members
451,512
Latest member
aimarhu

### 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.

### Which adblocker are you using?

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

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