# Can INDIRECT help here?

#### Tigerexcel

##### Active Member
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

#### njimack

##### Well-known Member
=SUMIF(B2:B9,"*Total",C2:C9)

#### Yongle

##### Well-known Member
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
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

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
A better solution would be to delete those hard-coded total rows, and use the built-in Subtotal function.

#### Tigerexcel

##### Active Member
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.

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.

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.

### Which adblocker are you using?

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

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