Calculate sum of top half rows in a column

tigertime

New Member
Joined
Jul 26, 2018
Messages
10
QLqaJEg.gif


Does any one know the formula to calculate top half rows/ bottom half rows of column D,
Simply by selecting ALL the rows in column D, as shown in the image

(I am not looking for the =SUM formula )

i have several tables like this and sometimes the number of rows may be odd/even
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Excel 2010
ABCDE
122
244
366
4100100
5200200
6First 1/2Second 1/2300300
7Column D126001000
8Column E6215509999
955555555
10
5aa
Cell Formulas
RangeFormula
B7=SUM(INDIRECT("D1"&":D"&INT(COUNT(D1:D7)/2)))+ISODD(COUNT(D1:D7))*MEDIAN(D1:D7)/2
B8=SUM(INDIRECT("E1"&":E"&INT(COUNT(E1:E7)/2)))+ISODD(COUNT(E1:E7))*MEDIAN(E1:E7)/2
C7=SUM(D1:D7)-B7
C8=SUM(E1:E7)-B8


N.B.
You can copy the mini example to a sheet and you can copy the formulas.
The HTML maker lets one post useful data and examples.
 
Last edited:
Upvote 0
Excel 2010
ABCDE
Column D
Column E

<tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]2[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]4[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]6[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]100[/TD]
[TD="align: right"]100[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]200[/TD]
[TD="align: right"]200[/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #F2F2F2"]First 1/2[/TD]
[TD="bgcolor: #F2F2F2"]Second 1/2[/TD]
[TD="align: right"]300[/TD]
[TD="align: right"]300[/TD]

[TD="align: center"]7[/TD]

[TD="align: right"]12[/TD]
[TD="align: right"]600[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1000[/TD]

[TD="align: center"]8[/TD]

[TD="align: right"]62[/TD]
[TD="align: right"]1550[/TD]
[TD="align: right"]99[/TD]
[TD="align: right"]99[/TD]

[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]5555[/TD]
[TD="align: right"]5555[/TD]

[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
5aa

[TABLE="width: 1249"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 1237"]
<tbody>[TR]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH]B7[/TH]
[TD]=SUM(INDIRECT("D1"&":D"&INT(COUNT(D1:D7)/2)))+ISODD(COUNT(D1:D7))*MEDIAN(D1:D7)/2[/TD]
[/TR]
[TR]
[TH]C7[/TH]
[TD]=SUM(D1:D7)-B7[/TD]
[/TR]
[TR]
[TH]B8[/TH]
[TD]=SUM(INDIRECT("E1"&":E"&INT(COUNT(E1:E7)/2)))+ISODD(COUNT(E1:E7))*MEDIAN(E1:E7)/2[/TD]
[/TR]
[TR]
[TH]C8[/TH]
[TD]=SUM(E1:E7)-B8[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

N.B.
You can copy the mini example to a sheet and you can copy the formulas.
The HTML maker lets one post useful data and examples.


Thanks! I tested it and it works well now...

i will be pasting this formula into several excel sheets,
on every sheet, its going to be different columns and rows

By any chance we can make it work by changing just 1 time on the formula where "D1"&":D" and "D1:D7" appears ,
so that i do not have to change 4 times on the formula whenever i paste the formula into another excel sheet ?
 
Last edited:
Upvote 0
You can use cell references in the formulas and/or named ranges but the best solution would require
an understanding of your challenges.



Excel 2010
ABCDE
1StartD1D22
2EndD744
366
4100100
5200200
6First 1/2Second 1/2300300
7Column D126001000
8Column E6215509999
955555555
10Column D12
11
12Column D12
13
14Column D12
5aa
Cell Formulas
RangeFormula
B7=SUM(INDIRECT("D1"&":D"&INT(COUNT(D1:D7)/2)))+ISODD(COUNT(D1:D7))*MEDIAN(D1:D7)/2
B8=SUM(INDIRECT("E1"&":E"&INT(COUNT(E1:E7)/2)))+ISODD(COUNT(E1:E7))*MEDIAN(E1:E7)/2
B10=SUM(INDIRECT(B1&":"&C1&INT(COUNT(rColD)/2)))+ISODD(COUNT(rColD))*MEDIAN(rColD)/2
B12=SUM(INDIRECT(B1&":"&C1&INT(COUNT(INDIRECT(B1&":"&B2))/2)))+ISODD(COUNT(rColD))*MEDIAN(rColD)/2
B14=SUM(INDIRECT(B1&":"&C1&INT(COUNT(INDIRECT(B1&":"&B2))/2)))+ISODD(COUNT(INDIRECT(B1&":"&B2)))*MEDIAN(INDIRECT(B1&":"&B2))/2
C7=SUM(D1:D7)-B7
C8=SUM(E1:E7)-B8
Named Ranges
NameRefers ToCells
rColD='5aa'!$D$1:$D$7
 
Upvote 0
You can use cell references in the formulas and/or named ranges but the best solution would require
an understanding of your challenges.


Excel 2010
ABCDE
StartD1D
EndD7
Column D
Column E
Column D
Column D
Column D

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"]2[/TD]
[TD="align: right"]2[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"][/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]4[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]6[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]100[/TD]
[TD="align: right"]100[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]200[/TD]
[TD="align: right"]200[/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #F2F2F2"]First 1/2[/TD]
[TD="bgcolor: #F2F2F2"]Second 1/2[/TD]
[TD="align: right"]300[/TD]
[TD="align: right"]300[/TD]

[TD="align: center"]7[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D8E4BC]#D8E4BC[/URL] , align: right"]12[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D8E4BC]#D8E4BC[/URL] , align: right"]600[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1000[/TD]

[TD="align: center"]8[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D8E4BC]#D8E4BC[/URL] , align: right"]62[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D8E4BC]#D8E4BC[/URL] , align: right"]1550[/TD]
[TD="align: right"]99[/TD]
[TD="align: right"]99[/TD]

[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]5555[/TD]
[TD="align: right"]5555[/TD]

[TD="align: center"]10[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D8E4BC]#D8E4BC[/URL] , align: right"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]12[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D8E4BC]#D8E4BC[/URL] , align: right"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]13[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]14[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D8E4BC]#D8E4BC[/URL] , align: right"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
5aa

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B7[/TH]
[TD="align: left"]=SUM(INDIRECT("D1"&":D"&INT(COUNT(D1:D7)/2)))+ISODD(COUNT(D1:D7))*MEDIAN(D1:D7)/2[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C7[/TH]
[TD="align: left"]=SUM(D1:D7)-B7[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B8[/TH]
[TD="align: left"]=SUM(INDIRECT("E1"&":E"&INT(COUNT(E1:E7)/2)))+ISODD(COUNT(E1:E7))*MEDIAN(E1:E7)/2[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C8[/TH]
[TD="align: left"]=SUM(E1:E7)-B8[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B10[/TH]
[TD="align: left"]=SUM(INDIRECT(B1&":"&C1&INT(COUNT(rColD)/2)))+ISODD(COUNT(rColD))*MEDIAN(rColD)/2[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B12[/TH]
[TD="align: left"]=SUM(INDIRECT(B1&":"&C1&INT(COUNT(INDIRECT(B1&":"&B2))/2)))+ISODD(COUNT(rColD))*MEDIAN(rColD)/2[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B14[/TH]
[TD="align: left"]=SUM(INDIRECT(B1&":"&C1&INT(COUNT(INDIRECT(B1&":"&B2))/2)))+ISODD(COUNT(INDIRECT(B1&":"&B2)))*MEDIAN(INDIRECT(B1&":"&B2))/2[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Workbook Defined Names[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Name[/TH]
[TH="align: left"]Refers To[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]rColD[/TH]
[TD="align: left"]='5aa'!$D$1:$D$7[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]


I only understand very basic excel, so it all seems quite difficult... i will now go and figure out how the above formulas work....

Thank you for all your replies and assistence ! :)
 
Upvote 0
to sum the first half of column D

=SUM(OFFSET(D:D, 0, 0, COUNTA(D:D)/2, 1)

to sum the second half
=SUM(OFFSET(D:D, COUNTA(D:D)/2,0, COUNTA(D:D), 1)
 
Upvote 0
Considering
a) you have data below the relevant range
b) with an odd number of entries, you want to split the mid number
c) using mikerickson's suggestion and dividing the mid number by 2 try

=SUM(OFFSET(rColE,0,0,COUNTA(rColE)/2,1))+ISODD(COUNT(rColE))*MEDIAN(rColE)/2
 
Upvote 0
Considering
a) you have data below the relevant range
b) with an odd number of entries, you want to split the mid number
c) using mikerickson's suggestion and dividing the mid number by 2 try

=SUM(OFFSET(rColE,0,0,COUNTA(rColE)/2,1))+ISODD(COUNT(rColE))*MEDIAN(rColE)/2

i do not understand what is the function/meaning of ISODD , so i modified your code for "Column E, 1st Half" to the following instead :
=SUM(OFFSET(E1:E7,0,0,COUNTA(E1:E7)/2,1))+MEDIAN(E1:E7)/2

This is what i am getting now (i still have no idea where is the html maker function, so i am pasting an image here ) :

rNu5zcG.gif
 
Last edited:
Upvote 0
Your questions
1. IsOdd See Excel's Help. True is equivalent to 1; false is equivalent to 0.
2. Try reviewing/evaluating the components of the formula. You can also use Excel's Formula Evaluate.
3. MrExcel's HTML Maker see the top posting in the forum Suggested Add-ins.
 
Upvote 0
Your questions
1. IsOdd See Excel's Help. True is equivalent to 1; false is equivalent to 0.
2. Try reviewing/evaluating the components of the formula. You can also use Excel's Formula Evaluate.
3. MrExcel's HTML Maker see the top posting in the forum Suggested Add-ins.

You have been very helpful, Thanks very much for all your advises !

Have a good week ahead :)
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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