Can INDIRECT help here?

Tigerexcel

Active Member
Joined
Mar 6, 2020
Messages
493
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Book7
BC
2NameSales
3Tom10
4Tom20
5Tom Total30
6Nick40
7Nick50
8Nick60
9Nick Total150
10Grand Total180
Sheet2


Received a file of which I've extracted a small part of. Problem is everything is hardcoded.
Can I use INDIRECT to help total the values, something like SUM(INDIRECT(B5&"Total")) to pick up the respective subtotals and place the overall total in the Grand Total cell?
Is there a better way to work out totals and quickly make the spreadsheet dynamic so that rows can be added/removed and totals update automatically?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows
How about
Book1
ABC
1
2NameSales
3Tom10
4Tom20
5Tom Total30
6Nick40
7Nick50
8Nick60
9Nick Total150
10Grand Total180
Sheet1
Cell Formulas
RangeFormula
C10C10=SUMIF(B3:B9,"*Total*",C3:C9)
 

Tigerexcel

Active Member
Joined
Mar 6, 2020
Messages
493
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Great solution Njimack and Yongle, that is a nice solution.
I wonder can cells C5 and C9 be converted to formulae via SUBSTITUTE or other functions? In other words, change them from hardcoded to actual formulae. I'm sure there's a VBA way of doing this, but is there another way just using Excel's functions?
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

I do not really ike it, but is seems to work!
Book1
ABC
1
2NameSales
3Tom10
4Tom20
5Tom Total30
6Nick40
7Nick50
8Nick60
9Nick Total150
10Grand Total180
Sheet1
Cell Formulas
RangeFormula
C5, C9C5=SUMIF($B$3:$B$9,SUBSTITUTE(B5," Total",""),$C$3:$C$9)
C10C10=SUMIF(B3:B9,"*Total*",C3:C9)
 

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,772
A better solution would be to delete those hard-coded total rows, and use the built-in Subtotal function.
 

Tigerexcel

Active Member
Joined
Mar 6, 2020
Messages
493
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I do not really ike it, but is seems to work!
Book1
ABC
1
2NameSales
3Tom10
4Tom20
5Tom Total30
6Nick40
7Nick50
8Nick60
9Nick Total150
10Grand Total180
Sheet1
Cell Formulas
RangeFormula
C5, C9C5=SUMIF($B$3:$B$9,SUBSTITUTE(B5," Total",""),$C$3:$C$9)
C10C10=SUMIF(B3:B9,"*Total*",C3:C9)
I don't mind it but you have to know where the totals are. The file I'm working has a number of subtotals so will take a little time to find them all.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,148
Messages
5,835,678
Members
430,374
Latest member
PeteBrown

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