Using variable in Median Formula

Davew01

New Member
Joined
Sep 17, 2006
Messages
7
I using the code below to select a starting row and column and an ending row and column. I then copy and paste the data in the next column to the right.

---------------------
ActiveSheet.Range(Cells(SR, SC), Cells(ER, EC)).Select ' Select active range
Selection.Copy
'Set A = ActiveSheet.Range.Select
ActiveCell.Offset(0, 1).Select
'Range.Cells(0,1)
'Range("I15").Select
Selection.PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False ' Paste Scores
Application.CutCopyMode = False
---------------
I would next like to perform a Median calculation on the data in the new column using variables to designate the start and end of the median calculation.

Example:

ActiveCell.FormulaR1C1 = "=MEDIAN(Cells(SR, SC):Cells(ER, EC))"

Is it possible to do something like this?

DaveW
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,911
Office Version
  1. 365
Platform
  1. Windows
Dave

Where are you setting the values of SR, SC, ER and EC?

Or are they named ranges?
 

Davew01

New Member
Joined
Sep 17, 2006
Messages
7
Variable in Median Formula

Those variables come from another section of the program. They represent the starting row (SR) and column (SC) and ending row and column (ER & EC). I am working on a program that locates Tournament golf scores vs regular play scores. Once I separate the Tournament scores into a vertical list using a loop that detects the start of the list (SR,SC) I copy this list into a separate column. I then want to determine the Median of the new column of scores.

One of my problems is that I am new to Excel VBA and macros. I have a lot of data that is exported into a XLS format a GHIN (golf handicap) program that I have to dig through and sort into just Tournament scores for about 300 players. Once I have each player’s set of tournament score separated into a new column I need to determine the median of the scores, select the median and all scores below the median and then run another formula to calculate Tournament handicap indexes. Since the scores are separated into new columns on the fly or dynamically I believe I need to use a variable in the median formula since I do not know ahead of time what the individual ranges are for each range of scores to put into the median formula.

Dave
 

Watch MrExcel Video

Forum statistics

Threads
1,112,797
Messages
5,542,558
Members
410,560
Latest member
1ndependent
Top