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
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Dave

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

Or are they named ranges?
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,252
Members
449,075
Latest member
staticfluids

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top