SUM in changeable range between two texts

Unexpc

Active Member
Joined
Nov 12, 2020
Messages
496
Office Version
  1. 2019
Platform
  1. Windows
Hi guys
How set a range for sum that changeable and add cells or remove cells in this range...
And show the result just in one cell not a specific column for this, how can i do this?
(For example instead of =SUM(D1:D30) if in the D1 cell written CUST A and in D30 CUST, just sum between this two texts (and show just in one specific cell) even if in this range add cells or remove)
 
Last edited:

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.
you can use index formulas to attain this as demonstrated below.

Enter the following formula in H3

=sUM(INDEX(D:D,MATCH(G1,D:D,0)):INDEX(D:D,MATCH(G2,D:D,0)))

1613800159439.png



Kind regards

Saba
 
Upvote 0
i can do like this between CUST B and CUST C and next CUST C and CUST D and....?
 
Upvote 0
For your first question, yes it will work

For your question, you can use the following formula

SUM(INDEX(D:D,MATCH(G1,D:D,0)):D:D,Sheet2!D:D:INDEX(Sheet2!D:D,MATCH(Sheet2!G2,Sheet2!D:D,0)))

this formula assumes the starting point in Sheet 1 and ending point in Sheet 2.

Kind regards

Saba
 
Upvote 0
For your first question, yes it will work

For your question, you can use the following formula

SUM(INDEX(D:D,MATCH(G1,D:D,0)):D:D,Sheet2!D:D:INDEX(Sheet2!D:D,MATCH(Sheet2!G2,Sheet2!D:D,0)))

this formula assumes the starting point in Sheet 1 and ending point in Sheet 2.

Kind regards

Saba
i change this formula in my range but steel not work and just show formula in cell
SUM(INDEX(D:E,MATCH(N3,D:E,0)):D:E,Start!D:E:INDEX(Start!D:E,MATCH(Start!N4,Start!D:E,0)))
in Sheet that name Start show sub-total of between Customer 1 and Customer 2 their in Sheet that name Paper
and written this two name in N3 and N4 in Sheet Strat
What am i wrong?
 
Upvote 0
Hello Unexp, I understand that you are bit frustrated getting a formula to do what you want to but the spreadsheet design commits a number of cardinal design sins that do not make it conducive to analysis.

Leveraging off what @Saba Sabaratnam did in response to your previous post and based on your latest attachments this should do what you want.
You will need to make the following corrections / modification to make it work:-
  • On Sheet 2
    • Correct the spelling of Customer A (currently Cutomer)
    • Add a last line which I have called "End of Customers" with the same row spacing (ei leave 1 blank row) as all your other Customer (A B C ..) headings
      This is to help the formula determine where the last valid customer finishes. The Row can be hidden, it should still work.
  • On Sheet 1
    • In Column A list all the Customer references in Sheet 2 column A ie Customer A, B, C etc and including End of Customers. This last one can be hidden but it needs to be there to determine where to end the previous customer.
20210226 Sum from SubTotal to SubTotal.xlsx
ABCD
1NameDateSum 1Sum 2
2Customer A20011476426,542
3Customer B2001142,184113,130
4Customer C000
5Other Customers000
6End of Customers
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=IFERROR(INDEX(Sheet2!B:B,MATCH($A3,Sheet2!A:A,0)-2,0),"")
C2:C5C2=IFERROR(SUM(INDEX(Sheet2!D:D,MATCH($A2,Sheet2!A:A,0)+1,0):INDEX(Sheet2!E:E,MATCH($A3,Sheet2!A:A,0)-2,0)),"")
D2:D5D2=IFERROR(SUM(INDEX(Sheet2!F:F,MATCH($A2,Sheet2!A:A,0)+1,0):INDEX(Sheet2!G:G,MATCH($A3,Sheet2!A:A,0)-2,0)),"")


The major spreadsheet design issues are:
  • Sheet 2 should be considered to be a data sheet and as such should have a column headed Customer and each line for each customer should have the Customer name on it ie all the Customer A lines should say "A" or customer A
  • Sheet 2 had merged cells on the row separating customers. Any experienced Excel user avoids merged cells like the plague.
Just those changes would make summarising the data a much simpler and more robust process and would allow the use of pivot tables which makes it more scalable as more customers are added.
It would also allow filtering to be applied to Sheet 2 should that be required.

Let me know if the formulas don't work for you or need explanation.
 
Last edited:
Upvote 0
Solution
I Test @Alex Blakenburg Method and its working. Only you need to add the same text at the end of Customer names at both sheet 1 & 2. if you don't want to see it change color of text to cell background color.
I add End of Customers to both sheets at the end of Both columns at both sheets.

Sheet2
Book1
ABCDEFG
1Customer ADateFNAGBGACBC
212001011000565656
32200102100147
43200103100258
54200104100322
65200105100434888
76200106100556
87200107100655
982001081007785454
109200109100861
1110200110100932
12112001111010555656
1312200112101166
1413200113101288
15142001141013568888
16
17Customer BDateFNAGBGACBC
181200101100088
1922001021001666
203200103100233
214200104100325
2252001051004645
236200106100522156565
247200107100665
258200108100756
269200109100854
2710200110100955
2811200111101055
2912200112101166
3013200113101289
311420011410136656565
32
33Customer C
34.
35.
36.200104
37
38End of Customers
Sheet2


Sheet1
Book1
ABCD
1NameDateSum 1Sum 2
2Customer A20011476426542
3Customer B2001142184113130
4Customer C20010400
5End of Customers   
6
7
8
9
10
11Last Formula I HaveLOOKUP(2,1/(Sheet2!B:B<>""),Sheet2!B:B)SUM(Sheet2!D3:D1048576)+SUM(Sheet2!E3:E1048576) or SUM(Sheet2!D3:E1048576)SUM(Sheet2!F3:G1048576)
12This Formulas was for every sheet i create but i want in one sheet and between two customer
13
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=IFERROR(INDEX(Sheet2!B:B,MATCH($A3,Sheet2!A:A,0)-2,0),"")
C2:C5C2=IFERROR(SUM(INDEX(Sheet2!D:D,MATCH($A2,Sheet2!A:A,0)+1,0):INDEX(Sheet2!E:E,MATCH($A3,Sheet2!A:A,0)-2,0)),"")
D2:D5D2=IFERROR(SUM(INDEX(Sheet2!F:F,MATCH($A2,Sheet2!A:A,0)+1,0):INDEX(Sheet2!G:G,MATCH($A3,Sheet2!A:A,0)-2,0)),"")
 
Upvote 0
I Test @Alex Blakenburg Method and its working. Only you need to add the same text at the end of Customer names at both sheet 1 & 2. if you don't want to see it change color of text to cell background color.
I add End of Customers to both sheets at the end of Both columns at both sheets.

Sheet2
Book1
ABCDEFG
1Customer ADateFNAGBGACBC
212001011000565656
32200102100147
43200103100258
54200104100322
65200105100434888
76200106100556
87200107100655
982001081007785454
109200109100861
1110200110100932
12112001111010555656
1312200112101166
1413200113101288
15142001141013568888
16
17Customer BDateFNAGBGACBC
181200101100088
1922001021001666
203200103100233
214200104100325
2252001051004645
236200106100522156565
247200107100665
258200108100756
269200109100854
2710200110100955
2811200111101055
2912200112101166
3013200113101289
311420011410136656565
32
33Customer C
34.
35.
36.200104
37
38End of Customers
Sheet2


Sheet1
Book1
ABCD
1NameDateSum 1Sum 2
2Customer A20011476426542
3Customer B2001142184113130
4Customer C20010400
5End of Customers   
6
7
8
9
10
11Last Formula I HaveLOOKUP(2,1/(Sheet2!B:B<>""),Sheet2!B:B)SUM(Sheet2!D3:D1048576)+SUM(Sheet2!E3:E1048576) or SUM(Sheet2!D3:E1048576)SUM(Sheet2!F3:G1048576)
12This Formulas was for every sheet i create but i want in one sheet and between two customer
13
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=IFERROR(INDEX(Sheet2!B:B,MATCH($A3,Sheet2!A:A,0)-2,0),"")
C2:C5C2=IFERROR(SUM(INDEX(Sheet2!D:D,MATCH($A2,Sheet2!A:A,0)+1,0):INDEX(Sheet2!E:E,MATCH($A3,Sheet2!A:A,0)-2,0)),"")
D2:D5D2=IFERROR(SUM(INDEX(Sheet2!F:F,MATCH($A2,Sheet2!A:A,0)+1,0):INDEX(Sheet2!G:G,MATCH($A3,Sheet2!A:A,0)-2,0)),"")
Yes you are right mabaadi im test again i find out i doing wrong in a part of formula
Thank You Alex Blakenburg, Great Work
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,858
Messages
6,121,956
Members
449,057
Latest member
FreeCricketId

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