View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jason Jason is offline
external usenet poster
 
Posts: 367
Default Formula - Dynamic Range

Figured it out. Made the following change and it worked. Thanks again.

ActiveCell.FormulaR1C1 = "=median(R" & firstrow & "C" & actcolumn & _
":R" & lastrow & "C" & actcolumn & ")"

"Jason" wrote:

Joel,

That almost gets me there... it is accurately pulling the beginning row and
the ending row, but for some reason it is including more columns than just
the current column. So for example, based on my sample data of the subject
being A5:A9, instead of Median($A$5:$A$9), it is giving me Median($A$5:$Y$9).
Any suggestions on how I can modify to fix this. Thanks for your help.

"Joel" wrote:

try this

firstrow = ActiveCell.Offset(-1, 0).End(xlUp).Row
actcolumn = ActiveCell.Column
lastrow = ActiveCell.Row - 1

ActiveCell.FormulaR1C1 = "=median(R" & firstrow & "C" & actcolumn & _
":R" & lastrow & "C" & lastrow & ")"