Sigma summation in Excel for accumulated value - excel

how can I use an iterative summation in Excel to compute the accumulated value starting amount (stored in one column) which escalates at 5 % p.a for n years (stored in another column) with the resultant amount then being subjected to a constraint. In essence, the raw function looks like:
where x = starting amount in a column, constraint is 10% of the amount less 80
Also, is my raw function okay to compute the accumulated value with the constraint?

To sum just one year:
Put n in cell A1, put x in cell A2:
=1.05^A1*0.1*A2-80
That will give you the value you're looking for.
To sum all of the years less than (and including) n down to 1:
Put n in cell A1, put x in cell A2:
=SUMPRODUCT(1.05^ROW(INDIRECT("1:"&A1))*(0.1*A2)-80)
Much the same, except that it's wrapped in a SUMPRODUCT() to allow for array formulas and the value given for n will return all positive integers less than (and including) n. The calculation is repeated n times and the result summed.
To sum all years less than (and including) n down to zero
=SUMPRODUCT(1.05^(-1+ROW(INDIRECT("1:"&A1+1)))*(0.1*A2)-80)
Same as answer #2, except it includes zero.

Related

Calculate maximum of a subrange in a table based on multiple conditions

I want to calculate the maximum amount of rain fallen on a day.
Column B contains the date as YYYYMMDD (value, not text)
Column C contains the number of the hour of measurement (ranging from 1 until 24)
Column N contains the amount of rain fallen in [mm] : 0 if no rain; positive integer if rain has fallen
What formula calculates the maximum amount of rain fallen on a day?
So:
for january 4th I want to sum N2:N25
for january 5th I want to sum N26:N49
etc.
and return the maximum of those calculated values
REMARK:
a value of -1 in column N indicates 'not measured' and shoudl be treated as 'no rain' (= 0)
I found one, my testing area only extended 1,000 rows, but it should scale nicely.
=MAX(SUMIFS(N2:N1000,B2:B1000,B2:B1000))
Remember to enter as an array formula by confirming with CNTRL + SHIFT + ENTER
Here's an ugly solution that takes 3 cells, but is much faster than my first formula:
=MAX(SUMIF(N2:N25,">"&0),SUMIF(N26:N49,">"&0),SUMIF(N50:N73,">"&0),SUMIF(N74:N97,">"&0),SUMIF(N98:N121,">"&0),SUMIF(N122:N145,">"&0),SUMIF(N146:N169,">"&0),SUMIF(N170:N193,">"&0),SUMIF(N194:N217,">"&0),SUMIF(N218:N241,">"&0),SUMIF(N242:N265,">"&0),SUMIF(N266:N289,">"&0),SUMIF(N290:N313,">"&0),SUMIF(N314:N337,">"&0),SUMIF(N338:N361,">"&0),SUMIF(N362:N385,">"&0),SUMIF(N386:N409,">"&0),SUMIF(N410:N433,">"&0),SUMIF(N434:N457,">"&0),SUMIF(N458:N481,">"&0),SUMIF(N482:N505,">"&0),SUMIF(N506:N529,">"&0),SUMIF(N530:N553,">"&0),SUMIF(N554:N577,">"&0),SUMIF(N578:N601,">"&0),SUMIF(N602:N625,">"&0),SUMIF(N626:N649,">"&0),SUMIF(N650:N673,">"&0),SUMIF(N674:N697,">"&0),SUMIF(N698:N721,">"&0),SUMIF(N722:N745,">"&0),SUMIF(N746:N769,">"&0),SUMIF(N770:N793,">"&0),SUMIF(N794:N817,">"&0),SUMIF(N818:N841,">"&0),SUMIF(N842:N865,">"&0),SUMIF(N866:N889,">"&0),SUMIF(N890:N913,">"&0),SUMIF(N914:N937,">"&0),SUMIF(N938:N961,">"&0),SUMIF(N962:N985,">"&0),SUMIF(N986:N1009,">"&0),SUMIF(N1010:N1033,">"&0),SUMIF(N1034:N1057,">"&0),SUMIF(N1058:N1081,">"&0),SUMIF(N1082:N1105,">"&0),SUMIF(N1106:N1129,">"&0),SUMIF(N1130:N1153,">"&0),SUMIF(N1154:N1177,">"&0),SUMIF(N1178:N1201,">"&0),SUMIF(N1202:N1225,">"&0),SUMIF(N1226:N1249,">"&0),SUMIF(N1250:N1273,">"&0),SUMIF(N1274:N1297,">"&0),SUMIF(N1298:N1321,">"&0),SUMIF(N1322:N1345,">"&0),SUMIF(N1346:N1369,">"&0),SUMIF(N1370:N1393,">"&0),SUMIF(N1394:N1417,">"&0),SUMIF(N1418:N1441,">"&0),SUMIF(N1442:N1465,">"&0),SUMIF(N1466:N1489,">"&0),SUMIF(N1490:N1513,">"&0),SUMIF(N1514:N1537,">"&0),SUMIF(N1538:N1561,">"&0),SUMIF(N1562:N1585,">"&0),SUMIF(N1586:N1609,">"&0),SUMIF(N1610:N1633,">"&0),SUMIF(N1634:N1657,">"&0),SUMIF(N1658:N1681,">"&0),SUMIF(N1682:N1705,">"&0),SUMIF(N1706:N1729,">"&0),SUMIF(N1730:N1753,">"&0),SUMIF(N1754:N1777,">"&0),SUMIF(N1778:N1801,">"&0),SUMIF(N1802:N1825,">"&0),SUMIF(N1826:N1849,">"&0),SUMIF(N1850:N1873,">"&0),SUMIF(N1874:N1897,">"&0),SUMIF(N1898:N1921,">"&0),SUMIF(N1922:N1945,">"&0),SUMIF(N1946:N1969,">"&0),SUMIF(N1970:N1993,">"&0),SUMIF(N1994:N2017,">"&0),SUMIF(N2018:N2041,">"&0),SUMIF(N2042:N2065,">"&0),SUMIF(N2066:N2089,">"&0),SUMIF(N2090:N2113,">"&0),SUMIF(N2114:N2137,">"&0),SUMIF(N2138:N2161,">"&0),SUMIF(N2162:N2185,">"&0),SUMIF(N2186:N2209,">"&0),SUMIF(N2210:N2233,">"&0),SUMIF(N2234:N2257,">"&0),SUMIF(N2258:N2281,">"&0),SUMIF(N2282:N2305,">"&0),SUMIF(N2306:N2329,">"&0),SUMIF(N2330:N2353,">"&0),SUMIF(N2354:N2377,">"&0),SUMIF(N2378:N2401,">"&0),SUMIF(N2402:N2425,">"&0),SUMIF(N2426:N2449,">"&0),SUMIF(N2450:N2473,">"&0),SUMIF(N2474:N2497,">"&0),SUMIF(N2498:N2521,">"&0),SUMIF(N2522:N2545,">"&0),SUMIF(N2546:N2569,">"&0),SUMIF(N2570:N2593,">"&0),SUMIF(N2594:N2617,">"&0),SUMIF(N2618:N2641,">"&0),SUMIF(N2642:N2665,">"&0),SUMIF(N2666:N2689,">"&0),SUMIF(N2690:N2713,">"&0),SUMIF(N2714:N2737,">"&0),SUMIF(N2738:N2761,">"&0),SUMIF(N2762:N2785,">"&0),SUMIF(N2786:N2809,">"&0),SUMIF(N2810:N2833,">"&0),SUMIF(N2834:N2857,">"&0),SUMIF(N2858:N2881,">"&0),SUMIF(N2882:N2905,">"&0),SUMIF(N2906:N2929,">"&0),SUMIF(N2930:N2953,">"&0),SUMIF(N2954:N2977,">"&0),SUMIF(N2978:N3001,">"&0),SUMIF(N3002:N3025,">"&0),SUMIF(N3026:N3049,">"&0),SUMIF(N3050:N3073,">"&0),SUMIF(N3074:N3097,">"&0),SUMIF(N3098:N3121,">"&0),SUMIF(N3122:N3145,">"&0),SUMIF(N3146:N3169,">"&0),SUMIF(N3170:N3193,">"&0),SUMIF(N3194:N3217,">"&0),SUMIF(N3218:N3241,">"&0),SUMIF(N3242:N3265,">"&0),SUMIF(N3266:N3289,">"&0),SUMIF(N3290:N3313,">"&0),SUMIF(N3314:N3337,">"&0),SUMIF(N3338:N3361,">"&0),SUMIF(N3362:N3385,">"&0),SUMIF(N3386:N3409,">"&0),SUMIF(N3410:N3433,">"&0),SUMIF(N3434:N3457,">"&0),SUMIF(N3458:N3481,">"&0),SUMIF(N3482:N3505,">"&0),SUMIF(N3506:N3529,">"&0),SUMIF(N3530:N3553,">"&0),SUMIF(N3554:N3577,">"&0),SUMIF(N3578:N3601,">"&0),SUMIF(N3602:N3625,">"&0),SUMIF(N3626:N3649,">"&0),SUMIF(N3650:N3673,">"&0),SUMIF(N3674:N3697,">"&0),SUMIF(N3698:N3721,">"&0),SUMIF(N3722:N3745,">"&0),SUMIF(N3746:N3769,">"&0),SUMIF(N3770:N3793,">"&0),SUMIF(N3794:N3817,">"&0),SUMIF(N3818:N3841,">"&0),SUMIF(N3842:N3865,">"&0),SUMIF(N3866:N3889,">"&0),SUMIF(N3890:N3913,">"&0),SUMIF(N3914:N3937,">"&0),SUMIF(N3938:N3961,">"&0),SUMIF(N3962:N3985,">"&0),SUMIF(N3986:N4009,">"&0),SUMIF(N4010:N4033,">"&0),SUMIF(N4034:N4057,">"&0),SUMIF(N4058:N4081,">"&0),SUMIF(N4082:N4105,">"&0),SUMIF(N4106:N4129,">"&0),SUMIF(N4130:N4153,">"&0),SUMIF(N4154:N4177,">"&0),SUMIF(N4178:N4201,">"&0),SUMIF(N4202:N4225,">"&0),SUMIF(N4226:N4249,">"&0),SUMIF(N4250:N4273,">"&0),SUMIF(N4274:N4297,">"&0),SUMIF(N4298:N4321,">"&0),SUMIF(N4322:N4345,">"&0),SUMIF(N4346:N4369,">"&0),SUMIF(N4370:N4393,">"&0),SUMIF(N4394:N4417,">"&0),SUMIF(N4418:N4441,">"&0),SUMIF(N4442:N4465,">"&0),SUMIF(N4466:N4489,">"&0),SUMIF(N4490:N4513,">"&0),SUMIF(N4514:N4537,">"&0),SUMIF(N4538:N4561,">"&0),SUMIF(N4562:N4585,">"&0),SUMIF(N4586:N4609,">"&0),SUMIF(N4610:N4633,">"&0),SUMIF(N4634:N4657,">"&0),SUMIF(N4658:N4681,">"&0),SUMIF(N4682:N4705,">"&0),SUMIF(N4706:N4729,">"&0),SUMIF(N4730:N4753,">"&0),SUMIF(N4754:N4777,">"&0),SUMIF(N4778:N4801,">"&0),SUMIF(N4802:N4825,">"&0),SUMIF(N4826:N4849,">"&0),SUMIF(N4850:N4873,">"&0),SUMIF(N4874:N4897,">"&0),SUMIF(N4898:N4921,">"&0),SUMIF(N4922:N4945,">"&0),SUMIF(N4946:N4969,">"&0),SUMIF(N4970:N4993,">"&0),SUMIF(N4994:N5017,">"&0),SUMIF(N5018:N5041,">"&0),SUMIF(N5042:N5065,">"&0),SUMIF(N5066:N5089,">"&0),SUMIF(N5090:N5113,">"&0),SUMIF(N5114:N5137,">"&0),SUMIF(N5138:N5161,">"&0),SUMIF(N5162:N5185,">"&0),SUMIF(N5186:N5209,">"&0),SUMIF(N5210:N5233,">"&0),SUMIF(N5234:N5257,">"&0))
And in a separate cell
=MAX(SUMIF(N5258:N5281,">"&0),SUMIF(N5282:N5305,">"&0),SUMIF(N5306:N5329,">"&0),SUMIF(N5330:N5353,">"&0),SUMIF(N5354:N5377,">"&0),SUMIF(N5378:N5401,">"&0),SUMIF(N5402:N5425,">"&0),SUMIF(N5426:N5449,">"&0),SUMIF(N5450:N5473,">"&0),SUMIF(N5474:N5497,">"&0),SUMIF(N5498:N5521,">"&0),SUMIF(N5522:N5545,">"&0),SUMIF(N5546:N5569,">"&0),SUMIF(N5570:N5593,">"&0),SUMIF(N5594:N5617,">"&0),SUMIF(N5618:N5641,">"&0),SUMIF(N5642:N5665,">"&0),SUMIF(N5666:N5689,">"&0),SUMIF(N5690:N5713,">"&0),SUMIF(N5714:N5737,">"&0),SUMIF(N5738:N5761,">"&0),SUMIF(N5762:N5785,">"&0),SUMIF(N5786:N5809,">"&0),SUMIF(N5810:N5833,">"&0),SUMIF(N5834:N5857,">"&0),SUMIF(N5858:N5881,">"&0),SUMIF(N5882:N5905,">"&0),SUMIF(N5906:N5929,">"&0),SUMIF(N5930:N5953,">"&0),SUMIF(N5954:N5977,">"&0),SUMIF(N5978:N6001,">"&0),SUMIF(N6002:N6025,">"&0),SUMIF(N6026:N6049,">"&0),SUMIF(N6050:N6073,">"&0),SUMIF(N6074:N6097,">"&0),SUMIF(N6098:N6121,">"&0),SUMIF(N6122:N6145,">"&0),SUMIF(N6146:N6169,">"&0),SUMIF(N6170:N6193,">"&0),SUMIF(N6194:N6217,">"&0),SUMIF(N6218:N6241,">"&0),SUMIF(N6242:N6265,">"&0),SUMIF(N6266:N6289,">"&0),SUMIF(N6290:N6313,">"&0),SUMIF(N6314:N6337,">"&0),SUMIF(N6338:N6361,">"&0),SUMIF(N6362:N6385,">"&0),SUMIF(N6386:N6409,">"&0),SUMIF(N6410:N6433,">"&0),SUMIF(N6434:N6457,">"&0),SUMIF(N6458:N6481,">"&0),SUMIF(N6482:N6505,">"&0),SUMIF(N6506:N6529,">"&0),SUMIF(N6530:N6553,">"&0),SUMIF(N6554:N6577,">"&0),SUMIF(N6578:N6601,">"&0),SUMIF(N6602:N6625,">"&0),SUMIF(N6626:N6649,">"&0),SUMIF(N6650:N6673,">"&0),SUMIF(N6674:N6697,">"&0),SUMIF(N6698:N6721,">"&0),SUMIF(N6722:N6745,">"&0),SUMIF(N6746:N6769,">"&0),SUMIF(N6770:N6793,">"&0),SUMIF(N6794:N6817,">"&0),SUMIF(N6818:N6841,">"&0),SUMIF(N6842:N6865,">"&0),SUMIF(N6866:N6889,">"&0),SUMIF(N6890:N6913,">"&0),SUMIF(N6914:N6937,">"&0),SUMIF(N6938:N6961,">"&0),SUMIF(N6962:N6985,">"&0),SUMIF(N6986:N7009,">"&0),SUMIF(N7010:N7033,">"&0),SUMIF(N7034:N7057,">"&0),SUMIF(N7058:N7081,">"&0),SUMIF(N7082:N7105,">"&0),SUMIF(N7106:N7129,">"&0),SUMIF(N7130:N7153,">"&0),SUMIF(N7154:N7177,">"&0),SUMIF(N7178:N7201,">"&0),SUMIF(N7202:N7225,">"&0),SUMIF(N7226:N7249,">"&0),SUMIF(N7250:N7273,">"&0),SUMIF(N7274:N7297,">"&0),SUMIF(N7298:N7321,">"&0),SUMIF(N7322:N7345,">"&0),SUMIF(N7346:N7369,">"&0),SUMIF(N7370:N7393,">"&0),SUMIF(N7394:N7417,">"&0),SUMIF(N7418:N7441,">"&0),SUMIF(N7442:N7465,">"&0),SUMIF(N7466:N7489,">"&0),SUMIF(N7490:N7513,">"&0),SUMIF(N7514:N7537,">"&0),SUMIF(N7538:N7561,">"&0),SUMIF(N7562:N7585,">"&0),SUMIF(N7586:N7609,">"&0),SUMIF(N7610:N7633,">"&0),SUMIF(N7634:N7657,">"&0),SUMIF(N7658:N7681,">"&0),SUMIF(N7682:N7705,">"&0),SUMIF(N7706:N7729,">"&0),SUMIF(N7730:N7753,">"&0),SUMIF(N7754:N7777,">"&0),SUMIF(N7778:N7801,">"&0),SUMIF(N7802:N7825,">"&0),SUMIF(N7826:N7849,">"&0),SUMIF(N7850:N7873,">"&0),SUMIF(N7874:N7897,">"&0),SUMIF(N7898:N7921,">"&0),SUMIF(N7922:N7945,">"&0),SUMIF(N7946:N7969,">"&0),SUMIF(N7970:N7993,">"&0),SUMIF(N7994:N8017,">"&0),SUMIF(N8018:N8041,">"&0),SUMIF(N8042:N8065,">"&0),SUMIF(N8066:N8089,">"&0),SUMIF(N8090:N8113,">"&0),SUMIF(N8114:N8137,">"&0),SUMIF(N8138:N8161,">"&0),SUMIF(N8162:N8185,">"&0),SUMIF(N8186:N8209,">"&0),SUMIF(N8210:N8233,">"&0),SUMIF(N8234:N8257,">"&0),SUMIF(N8258:N8281,">"&0),SUMIF(N8282:N8305,">"&0),SUMIF(N8306:N8329,">"&0),SUMIF(N8330:N8353,">"&0),SUMIF(N8354:N8377,">"&0),SUMIF(N8378:N8401,">"&0),SUMIF(N8402:N8425,">"&0),SUMIF(N8426:N8449,">"&0),SUMIF(N8450:N8473,">"&0),SUMIF(N8474:N8497,">"&0),SUMIF(N8498:N8521,">"&0),SUMIF(N8522:N8545,">"&0),SUMIF(N8546:N8569,">"&0),SUMIF(N8570:N8593,">"&0),SUMIF(N8594:N8617,">"&0),SUMIF(N8618:N8641,">"&0),SUMIF(N8642:N8665,">"&0),SUMIF(N8666:N8689,">"&0),SUMIF(N8690:N8713,">"&0),SUMIF(N8714:N8737,">"&0),SUMIF(N8738:N8761,">"&0),SUMIF(N8762:N8785,">"&0))
The Max() of these two cells is the total for the year. It's brute force but it solves the speed issue.

Excel formula: make the average depending on a cell

I want to make a formula that turns in a VBA code that makes the average for column A even though there are some 0 there. I want to divide it by a the number in a cell that counts the objects in column A.
I used to use this formula, but it divides my sum incorrectly because I have 0's (I want to keep the 0's there):
=AVERAGE(Sheet1!$B$2:$B$10000)
The easiest way to do this, is to get the total of column B by using sum(B:B) (or a more specific range, if you want), and the amount of non-blank cells in column A by using counta(A:A) (in my comment I used count which only counts the amount of numbers in the range, counta should count all non-blank cells). You can then divide the former by the latter to get the number you are looking for, resulting in a formula looking something like
=SUM(B:B)/COUNTA(A:A)
If you already have the count of column A in a cell (e.g. E3), it's even simpler, just use something like
=SUM(B:B)/E3
You can use AverageIf for such a purpose, as you can see in my example:
Row/Column A B C D
1
2 2 =AVERAGE(B2:B5) => value 3
3 4 =AVERAGEIF(B2:B5;"<>0") => value 4
4 0
5 6

Median Selling Price Excel Table

I have a spreadsheet with different products, listing units and retail value sold like the example below
Product Units Value
A 10 100
B 15 80
C 30 560
I'd like to compare the Average Selling Price with the Median Selling price, so I am looking for a quick formula to accurately calculate the median.
The median function requires the entire series, so for Product A above I would need 10 instances of 10 etc. How can I calculate the Median quickly considering the condensed form of my data?
Without writing your own VBA function to do this there are a couple of approaches that can be taken.
The first expands the data from its compressed frequency count format to generate the full set of observations. This can be done manually or formulaically. On the assumption the latter is required, it can be achieved using a few columns.
All the blue cells are formulae.
Column Eis simply the cumulative of column B and F is an adjusted version of this. Column H is just the values 1 to 55, the total number of observations given by cell L2. Column I uses the MATCH() with its final argument as 1 to match each observation in H against the adjusted cumulative in F. Column J uses the INDEX() function to generate the value of the observation. (Observations 1-10 have value 100, 11-25 have value 80 and 26-55 have value 560 in this example). The MEDIAN() function is used in cell M2 with column J as its argument.
This approach can be refined to take account of varying numbers of products and data points through the use of the OFFSET function to control the range arguments of the MATCH(), INDEX() and MEDIAN functions. And, of course, adjacent cells in columns I and J could be combined using a single formula - I've shown them separately for ease of explanation.
The second approach involves sorting the data by value (so in this case the data rows would become Product B in row 2, product A in row 3 and product C left as-is in row 4). It is then a case of identifying the middle observation number (if the number of observations is odd) or the middle pair of observation numbers (if the number of observations is even) and then determining the value(s) corresponding to this/these middle observation(s). In this approach the adjusted cumulative in column F is still used but rather than explicitly calculating the values in column I and J for every observation it can now be restricted to just the middle observation(s).
I think there is no way around compromises. Either using big amounts of helper cells or having the table sorted by the values.
Helper cells:
Formula in F4:AS6:
=IF(COLUMN()<COLUMN($F$4)+$B4,$C4,"end")
Formula in D2:
=MEDIAN(F4:AS6)
Sorted:
Formula in F4 downwards:
=SUM($B$3:B3)+1
Formula in D2:
=SUM(LOOKUP(INT(SUM(B4:B6)/2+{0.5,1}),F4:F6,C4:C6))/2

Excel: Sum of largest numbers

Excel offers the function LARGE, and when combined with SUM, it allows summing up the top N largest numbers. This works fine for cases where the area from which these numbers are drawn is continuous, for example with this examlple:
SUM(LARGE(A1:A10),{1,2,3,4,5,6,7}
This would extract the top 7 largest numbers from an area of 10 cells (that are contingious). How do I do that if I have only every second cell, i.e. I want to use A1, A3, A5, ... ?
Here the data in the spreadsheet:
A B C D E
3.5 80 2.5 90 5.5
I want to find the largest number from 3.5, 2.5, 5.5 etc... The ONLY condition that exists between neighbour numbers (e.g. A and B) is that B is always larger than the other. The reason why I need to keep both numbers is purely for reasons of completeness.
In short: How do I use the LARGE function with a set distributed individual cells?
Try this formula:
=SUM(LARGE(INDEX((MOD(COLUMN($A$1:$E$1),2)=1)*$A$1:$E$1,),{1,2,3}))

Ranking in Excel with multiple criteria

For example, I need to create a merit list of few student based on total marks (column C), then higher marks in math (column B) -
A B C D
-------------------------
Student1 80 220 1
Student2 88 180 3
Student3 90 180 2
Expected merit position is given in column D.
I can use RANK function but I can only do that for one column (total number). If total number of multiple student is equal, I could not find any solution of this.
You can try this one in D1
=COUNTIF($C$1:$C$99,">"&C1)+1+SUMPRODUCT(--($C$1:$C$99=C1),--($B$1:$B$99>B1))
and then copy/fill down.
let me know if this helps.
Explanation
Your first criteria sits in column C, and the second criteria sits in Column B.
Basically, first it is counting the number of entries ($C$1:$C$99) that are bigger than the entry itself ($C1). For the first one in the ranking, you will get zero, therefore you need to add 1 to each result (+1).
Until here, you will get duplicate rankings if you have the same value twice. Therefore you need to add another argument to do some extra calculations based on the second criteria:
To resolve the tie situation, you need to sumproduct two array formulas and add the result to the previous argument, the goal is to find the number of entries that are equal to this entry with $C$1:$C$99=C1 and have a bigger value in the second criteria column $B$1:$B$99>B1:
you add -- to convert TRUE and FALSE to 0s and 1s so that you can multiply them:
SUMPRODUCT(--($C$1:$C$99=C1),--($B$1:$B$99>B1))
the first array is to see how many ties you have in the first criteria. And the second array is to find the number of bigger values than the entry itself.
Note you can add as many entries as you like to your columns, but remember to update the ranges in the formula, currently it is set to 99, you can extend it to as many rows as you want.
Sometimes a helper column will provide a quick and calculation-efficient solution. Adding the math marks to the total marks as a decimal should produce a number that will rank according to your criteria. In an unused column to the right, use this formula in row 2,
=C2+B2/1000
Fill down as necessary. You can now use a conventional RANK function on this helper column like =RANK(D2, D$2:D$9) for your ranking ordinals.
Very simple (or, at least, much more simpler that the one provided by the best answer) 'math' solution: do a linear combination with weights.
Do something like
weighted_marks = 10*colC + colB
then sort weighted marks using simple rank function.
It does solve your problem, bulding the ranking you need.
If you don't like to limit the number of rows or the numbers used in the criteria, Jeeped's approach can be extended. You can use the following formulas in cells D2 to L2, assuming that there are three criteria, the first one in column A, the second one in column B, and the third one in column C:
=RANK($A2,$A:$A,1)
=RANK($B2,$B:$B,1)
=D2*2^27+E2
=RANK(F2,F:F,1)
=RANK($C2,$C:$C,1)
=G2*2^27+H2
=RANK(I2,I:I,1)
=J2*2^27-ROW()
=RANK(K2,K:K,0)
The formulas have to be copied down. The result is in column L. Ties are broken using the row number.
If you like to add a fourth criterion, you can do the following after having the formulas above in place:
Add the new criterion between columns C and D.
Insert three new columns between columns I and J.
Copy columns G:I to the new columns J:L.
Copy column G to column M, overwriting its content.
Change the formula in column L to point to the new criterion.
The factor 2^27 used in the formulas balances the precision of 53 bits available in double-precision numbers. This is enough to cover the row limit of current versions of Excel.

Resources