Sum across variable columns

coop123

Board Regular
Joined
Dec 18, 2018
Messages
66
Office Version
  1. 365
Hi

I think this may already have been answered but I cannot find a solution.

I have a macro in which i want to sum up the values across multiple columns. The number of columns will vary each time report is run.

See example spreadsheet.

In the example in D4 I want to sum all values in K4 to CU4, then copy formula down to D27 summing up each row separately.

End range for row 4 can vary but will always start at K4
End range for formula in column D will vary but will always start at D4.

Thanks

Regards

coop123

mr excel.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCU
1Components9.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+089.48E+0824222420CH24222420D24222420R0124223020D24223020KW24223020R0124223020RU24223410CH24223410R0124223420CH24223420D24223420GB24223420R0124224020GB24224020R0124224120USA24601250CH24601250D24601250GB24601250R0124601250RU24714040D24714040R0124724040D24724040GB24724040KW24724040R0124724040RU24724040USA24724410R0124724410RU24724420CH24724420R0124724430R0124724440CH24724440D24724440GB24724440R01EBA2748WOSP30100SSEVMDD5306SSICBSPO30TE/SMDD30CM/B/THMDD30TE/S/TH
2month data is for6155819878214829646918973712627232241501272023100151305311114894402801220040407448010040126041172147232757838530142030203792034342550752401415019261701010011394105040100520120424830120203483040216049534168352352
3Total Qty
4FPADBA020URK519700000000000000000000000000000000000000000000000000000000000001100194100000000000000000000000
5FPADBA021URK400000000000000000000000000000000000000000000000000000000000001100194100000000000000000000000
6FPADBA075URK10000000000000000000000000000000000000000000000000000000000000000000000000000000000000002704
7FPADBA085URK00000000000000000000000000000000000000000000000000000000000000000000000000000000000000016800
8FPADBA086URK00000000000000000000000000000000000000000000000000000000000000000000000000000000000000016800
9FPADBA089URK000000000000000000000000000000000000000000000000000000000000000000050110012014130120148140160000000
10FPADBA092URK1055800014690007212410127123015100011400000000000014110007510001301379134312517511410000000000000000000000000000000
11FPADBA093URK0055800014690007212410127123015100011400000000000014110007510001301379134312517511410000000000000000000000000000000
12FPADBA094URK000000000000000000000000000000000000000000000000000000000000000000050110012014130120148140160000000
13FPADBA097URK0001987100013711000000010000014000040001100000000100011400000000000000000000000000000000000000000000
14FPADBA098URK000000000000000000100000100000000000000010001000000000000000000000000000000000000000000000
15FPADBA099URK000000000000000000100000100000000000000010001000000000000000000000000000000000000000000000
16FPADBA101URK000198700000371000000000000000400000000000000000000000000000000000000000000000000000000000000000
17FPADBA102URK000198700000371000000000000000400000000000000000000000000000000000000000000000000000000000000000
18FPADBA104URK000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000
19FPADBA105URK000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000
20FPADBA106URK0000100010100000000000000000040001100000000000001400000000000000000000000000000000000000000000
21FPADBA107URK0000100010100000000000000000040001100000000000001400000000000000000000000000000000000000000000
22FPADBA108URK000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000
23FPADBA113URK000000000000000000000000000000000000000000000000000000000000000000000000000000000000031000
24FPADBA114URK000000000000000000000000000000000000000000000000000000000000000000000000000000000000031000
25FPADBA115URK06100048000000001000001531000112100740011200114700038000000000000000191700000000000000000000000000000
26FPADBA116URK06100048000000001000001531000112100740011200114700038000000000000000191700000000000000000000000000000
27FPADBA117URK06100048000000001000001531000112100740011200114700038000000000000000191700000000000000000000000000000
Sheet1
Cell Formulas
RangeFormula
D4D4=SUM(K4:CU4)
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
the number of columns will vary each time report is run.
How would we know how many columns for a particular report run?
If there is nothing further to the right, couldn't you just always add from column K across to column, say, ZZ?
 
Upvote 0
Solution
Hi Peter_SSs

Thanks for the pointer. I was over thinking the process. I can extend the formula to cover the furthest column.

Keeping it simple is best solution.

Thanks

coop123
 
Upvote 0
You're welcome. Just need a second pair of eyes sometimes. :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
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