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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,303
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
 

Forum statistics

Threads
1,141,427
Messages
5,706,377
Members
421,446
Latest member
rena jhon

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
Top