Replace Subtotal with Sum

cagauravgarg

New Member
Joined
Mar 17, 2023
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Is there any shortcut way to replace the Subtotal formula in groupings with Sum formula? I have multiple level of groupings in the excel. Attached an image for example

1679066211072.png
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Perhaps you could use CTRL+F and, select the Replace tab and put:
Find what: =SUBTOTAL(9,
Replace with: =SUM(
Change the look in box to: Formulas

Click Replace All
 
Upvote 0
Hi,
Usually, the challenge is exactly the opposite !!! Converting SUMs to SUBTOTALs
What is your final objective ???
 
Upvote 0
No Find and replace won't work. Say there are 11 rows and A1 to A11 and have 2 groupings each 5 times and then I have total of all 5 grouping in 11th row. By doing replace the formula in 11th row will be like =Sum(A1:A10) which is wrong as it will add individual sum of all the 5 groupings in between. However subtotal ignores subtotal applied within in its range.
 
Upvote 0
Is there any shortcut way to replace the Subtotal formula in groupings with Sum formula? I have multiple level of groupings in the excel. Attached an image for example

View attachment 87738
Try this👇
Press ctrl + ~
Then go to replace and type
=SUBTOTAL(9,
in find what field and
=sum(
in "Replace with" field and press "Replace All" button
Press again ctrl + ~
Hope this might help!!
 
Upvote 0
@Ajeet

I'm aware of the shortcuts that you have mentioned but it doesn't work. Here is a sample of the excel range. I have applied the subtotal formula in rows 11, 19 and 20. Now if I use find and replace and convert those formulas to sum, rows 11 and 19 will not have any impact, but the total value in Row 20 will be impacted. This is just a sample range I have multiple levels of groupings having 5k+ rows. I can't do this manually.

Book1
ABCDEFG
1
2Location IS -
3
4Acct #Unique ID$'000Jan-20Feb-20
5Regular
6501.1501.1 - Retail tiresRetail tires12
7501.10501.10 - LaborLabor12
8501.7501.7 - Commercial tireCommercial tire12
9501.4501.4 - ChainsChains12
10501501 - SalesSales34232
11Regular34640
12Miscellaneous
13501.90501.90 - Finance chargeFinance charge12
14501.9.5501.9.5 - Oregon state surchargeOregon state surcharge12
15501.9.4501.9.4 - Merchant services fraudMerchant services fraud12
16501.9.3501.9.3 - Nat. account charge backNat. account charge back12
17501.9.2501.9.2 - PinmarxPinmarx12
18501.9501.9 - Misc salesMisc sales1231
19Miscellaneous1741
20Net sales36381
21
Sheet3
Cell Formulas
RangeFormula
D2D2="Location IS - "&D1
F4F4=EOMONTH(E4,1)
C6:C10,C13:C18C6=B6&" - "&D6
D11D11=D5
E11:F11E11=SUBTOTAL(9,E6:E10)
D19D19=D12
E19:F19E19=SUBTOTAL(9,E12:E18)
E20:F20E20=SUBTOTAL(9,E5:E19)
 
Upvote 0
You did not answer the question in post # 3 ...

For sure, you already know that for your Grand Total, Subtotal will only sum all the subtotals located above ...
 
Upvote 0
If I had applied subtotal it ignores all the subtotal applied above. But the Sum will do the opposite so I just can't use find and replace over this. Actually, this is just to ensure my databook is consistent. All my other tabs are prepared using Sum so I can't use subtotal in this file. My objective is meet the client requirements that's all
 
Upvote 0
Hi again,

Despite the fact I do not understand your situation ...
You can test following
VBA Code:
Sub ChangeCellFormula()
Dim rng As Range, rngform As String
    Set rng = Range("E11")
    rngform = rng.Formula
    rngform = Replace(rngform, "SUBTOTAL(9,", "SUM(")
    rng.Formula = rngform
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,535
Members
449,169
Latest member
mm424

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