Excel how to sum all cells with the same name
I have a workbook with 30 or more sheets. Specifically, each sheet may be an invoice, change order, etc. such that the format of each sheet is not the same as the next one.
The named range Total on each sheet may refer to one or more random cells on that sheet. On the last sheet, I want one cell to show the sum of all cells named Total.
The number of sheets may vary. I do not want to use a pivot table.
Is this possible?
Addendum: The formula below will return the total of all cells that belong to any name "Total" on any of the listed sheets, but I would like to automate it so I don't have to manually add all of the sheet names. The name Total may refer to one cell or any collection of cells on each sheet. In actual use, the sheet names could be any random name. So, I'm looking for code that will look at each sheet, and if the sheet contains the name Total then it appends +SUM(sheetname!(Total) to the equation. The SUM function is necessary so that if there are two or more cells per sheet in the named range Total, then they are included in the GrandTotal.
=SUM(Sheet1!Total)+SUM(Sheet2!Total)+SUM(Sheet3!Total)+SUM(Sheet4!Total)
Another example: The following shows why I think it's possible to do what I want in a single step. Formulas=GET.CELL(48,INDIRECT("rc",0)) creates a real-time dynamic named range "Formulas" that includes every cell in the workbook which contains a formula. You can then conditionally format all cells to have a shaded background when the cell contains a formula.
So, I'm looking for a function something like: GrandTotal=SUM(GET.CELL("Total",INDERECT("rc",0)) where Total efers to any cell that belongs to a range named Total.
microsoft-excel worksheet-function range
add a comment |
I have a workbook with 30 or more sheets. Specifically, each sheet may be an invoice, change order, etc. such that the format of each sheet is not the same as the next one.
The named range Total on each sheet may refer to one or more random cells on that sheet. On the last sheet, I want one cell to show the sum of all cells named Total.
The number of sheets may vary. I do not want to use a pivot table.
Is this possible?
Addendum: The formula below will return the total of all cells that belong to any name "Total" on any of the listed sheets, but I would like to automate it so I don't have to manually add all of the sheet names. The name Total may refer to one cell or any collection of cells on each sheet. In actual use, the sheet names could be any random name. So, I'm looking for code that will look at each sheet, and if the sheet contains the name Total then it appends +SUM(sheetname!(Total) to the equation. The SUM function is necessary so that if there are two or more cells per sheet in the named range Total, then they are included in the GrandTotal.
=SUM(Sheet1!Total)+SUM(Sheet2!Total)+SUM(Sheet3!Total)+SUM(Sheet4!Total)
Another example: The following shows why I think it's possible to do what I want in a single step. Formulas=GET.CELL(48,INDIRECT("rc",0)) creates a real-time dynamic named range "Formulas" that includes every cell in the workbook which contains a formula. You can then conditionally format all cells to have a shaded background when the cell contains a formula.
So, I'm looking for a function something like: GrandTotal=SUM(GET.CELL("Total",INDERECT("rc",0)) where Total efers to any cell that belongs to a range named Total.
microsoft-excel worksheet-function range
Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.
– DavidPostill♦
Mar 25 '16 at 23:26
In the first place, how did you give the same name to ranges in different sheet? I'm on Excel 2016 and I'm unable to replicate your situation
– Prasanna
Mar 26 '16 at 1:21
Prasanna - Excel has two levels of named ranges, workbook level, and worksheet level. Here's one way to change it: Start with a single blank sheet. Name your ranges; these will most likely be workbook level ranges by default. Now right-click the sheet tab and copy to a new sheet. The new sheet will have worksheet level ranges. Delete the original sheet. If you continue to make copies of the sheet they will be worksheet level named ranges.
– Dickie Dunkin
Mar 27 '16 at 14:08
Regarding your example with theFormulas
named range to shade cells with a formula: The formula you've given does not work as a named range on which you can perform functions. It returns eitherTRUE
orFALSE
depending on whether or not a particular cell has a formula in it. If you use it for conditional formatting and apply it to a large range, it will evaluate each cell individually.
– Engineer Toast
Mar 28 '16 at 20:45
To learn more aboutGet.Cell
, take a look here
– Engineer Toast
Mar 28 '16 at 20:46
add a comment |
I have a workbook with 30 or more sheets. Specifically, each sheet may be an invoice, change order, etc. such that the format of each sheet is not the same as the next one.
The named range Total on each sheet may refer to one or more random cells on that sheet. On the last sheet, I want one cell to show the sum of all cells named Total.
The number of sheets may vary. I do not want to use a pivot table.
Is this possible?
Addendum: The formula below will return the total of all cells that belong to any name "Total" on any of the listed sheets, but I would like to automate it so I don't have to manually add all of the sheet names. The name Total may refer to one cell or any collection of cells on each sheet. In actual use, the sheet names could be any random name. So, I'm looking for code that will look at each sheet, and if the sheet contains the name Total then it appends +SUM(sheetname!(Total) to the equation. The SUM function is necessary so that if there are two or more cells per sheet in the named range Total, then they are included in the GrandTotal.
=SUM(Sheet1!Total)+SUM(Sheet2!Total)+SUM(Sheet3!Total)+SUM(Sheet4!Total)
Another example: The following shows why I think it's possible to do what I want in a single step. Formulas=GET.CELL(48,INDIRECT("rc",0)) creates a real-time dynamic named range "Formulas" that includes every cell in the workbook which contains a formula. You can then conditionally format all cells to have a shaded background when the cell contains a formula.
So, I'm looking for a function something like: GrandTotal=SUM(GET.CELL("Total",INDERECT("rc",0)) where Total efers to any cell that belongs to a range named Total.
microsoft-excel worksheet-function range
I have a workbook with 30 or more sheets. Specifically, each sheet may be an invoice, change order, etc. such that the format of each sheet is not the same as the next one.
The named range Total on each sheet may refer to one or more random cells on that sheet. On the last sheet, I want one cell to show the sum of all cells named Total.
The number of sheets may vary. I do not want to use a pivot table.
Is this possible?
Addendum: The formula below will return the total of all cells that belong to any name "Total" on any of the listed sheets, but I would like to automate it so I don't have to manually add all of the sheet names. The name Total may refer to one cell or any collection of cells on each sheet. In actual use, the sheet names could be any random name. So, I'm looking for code that will look at each sheet, and if the sheet contains the name Total then it appends +SUM(sheetname!(Total) to the equation. The SUM function is necessary so that if there are two or more cells per sheet in the named range Total, then they are included in the GrandTotal.
=SUM(Sheet1!Total)+SUM(Sheet2!Total)+SUM(Sheet3!Total)+SUM(Sheet4!Total)
Another example: The following shows why I think it's possible to do what I want in a single step. Formulas=GET.CELL(48,INDIRECT("rc",0)) creates a real-time dynamic named range "Formulas" that includes every cell in the workbook which contains a formula. You can then conditionally format all cells to have a shaded background when the cell contains a formula.
So, I'm looking for a function something like: GrandTotal=SUM(GET.CELL("Total",INDERECT("rc",0)) where Total efers to any cell that belongs to a range named Total.
microsoft-excel worksheet-function range
microsoft-excel worksheet-function range
edited Mar 27 '16 at 16:23
Dickie Dunkin
asked Mar 25 '16 at 22:53
Dickie DunkinDickie Dunkin
12
12
Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.
– DavidPostill♦
Mar 25 '16 at 23:26
In the first place, how did you give the same name to ranges in different sheet? I'm on Excel 2016 and I'm unable to replicate your situation
– Prasanna
Mar 26 '16 at 1:21
Prasanna - Excel has two levels of named ranges, workbook level, and worksheet level. Here's one way to change it: Start with a single blank sheet. Name your ranges; these will most likely be workbook level ranges by default. Now right-click the sheet tab and copy to a new sheet. The new sheet will have worksheet level ranges. Delete the original sheet. If you continue to make copies of the sheet they will be worksheet level named ranges.
– Dickie Dunkin
Mar 27 '16 at 14:08
Regarding your example with theFormulas
named range to shade cells with a formula: The formula you've given does not work as a named range on which you can perform functions. It returns eitherTRUE
orFALSE
depending on whether or not a particular cell has a formula in it. If you use it for conditional formatting and apply it to a large range, it will evaluate each cell individually.
– Engineer Toast
Mar 28 '16 at 20:45
To learn more aboutGet.Cell
, take a look here
– Engineer Toast
Mar 28 '16 at 20:46
add a comment |
Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.
– DavidPostill♦
Mar 25 '16 at 23:26
In the first place, how did you give the same name to ranges in different sheet? I'm on Excel 2016 and I'm unable to replicate your situation
– Prasanna
Mar 26 '16 at 1:21
Prasanna - Excel has two levels of named ranges, workbook level, and worksheet level. Here's one way to change it: Start with a single blank sheet. Name your ranges; these will most likely be workbook level ranges by default. Now right-click the sheet tab and copy to a new sheet. The new sheet will have worksheet level ranges. Delete the original sheet. If you continue to make copies of the sheet they will be worksheet level named ranges.
– Dickie Dunkin
Mar 27 '16 at 14:08
Regarding your example with theFormulas
named range to shade cells with a formula: The formula you've given does not work as a named range on which you can perform functions. It returns eitherTRUE
orFALSE
depending on whether or not a particular cell has a formula in it. If you use it for conditional formatting and apply it to a large range, it will evaluate each cell individually.
– Engineer Toast
Mar 28 '16 at 20:45
To learn more aboutGet.Cell
, take a look here
– Engineer Toast
Mar 28 '16 at 20:46
Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.
– DavidPostill♦
Mar 25 '16 at 23:26
Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.
– DavidPostill♦
Mar 25 '16 at 23:26
In the first place, how did you give the same name to ranges in different sheet? I'm on Excel 2016 and I'm unable to replicate your situation
– Prasanna
Mar 26 '16 at 1:21
In the first place, how did you give the same name to ranges in different sheet? I'm on Excel 2016 and I'm unable to replicate your situation
– Prasanna
Mar 26 '16 at 1:21
Prasanna - Excel has two levels of named ranges, workbook level, and worksheet level. Here's one way to change it: Start with a single blank sheet. Name your ranges; these will most likely be workbook level ranges by default. Now right-click the sheet tab and copy to a new sheet. The new sheet will have worksheet level ranges. Delete the original sheet. If you continue to make copies of the sheet they will be worksheet level named ranges.
– Dickie Dunkin
Mar 27 '16 at 14:08
Prasanna - Excel has two levels of named ranges, workbook level, and worksheet level. Here's one way to change it: Start with a single blank sheet. Name your ranges; these will most likely be workbook level ranges by default. Now right-click the sheet tab and copy to a new sheet. The new sheet will have worksheet level ranges. Delete the original sheet. If you continue to make copies of the sheet they will be worksheet level named ranges.
– Dickie Dunkin
Mar 27 '16 at 14:08
Regarding your example with the
Formulas
named range to shade cells with a formula: The formula you've given does not work as a named range on which you can perform functions. It returns either TRUE
or FALSE
depending on whether or not a particular cell has a formula in it. If you use it for conditional formatting and apply it to a large range, it will evaluate each cell individually.– Engineer Toast
Mar 28 '16 at 20:45
Regarding your example with the
Formulas
named range to shade cells with a formula: The formula you've given does not work as a named range on which you can perform functions. It returns either TRUE
or FALSE
depending on whether or not a particular cell has a formula in it. If you use it for conditional formatting and apply it to a large range, it will evaluate each cell individually.– Engineer Toast
Mar 28 '16 at 20:45
To learn more about
Get.Cell
, take a look here– Engineer Toast
Mar 28 '16 at 20:46
To learn more about
Get.Cell
, take a look here– Engineer Toast
Mar 28 '16 at 20:46
add a comment |
2 Answers
2
active
oldest
votes
You can write in the summary sheet 2 columns for each invoice write the name of the sheet
Invoice Total
Sheet1
Sheet2
Sheet7
if sheet1 is in A2, in the second column :
=INDIRECT(A2&"!"&"total")
you will have the value of total invoice then you can add it for Grand Total
add a comment |
Old question, but maybe it helps someone with the same problem. I had the same issue and wrote a function for it:
Public Function SumNamedRanges(nm As String) As Double
Dim sh As Worksheet
Dim test As Range
For Each sh In Sheets
' check if the named range exists
On Error Resume Next
Set test = sh.Range(nm)
If Err.Number = 0 Then
On Error GoTo 0
' sum the ranges
SumNamedRanges = SumNamedRanges + _
Application.WorksheetFunction.Sum(test)
Else
On Error GoTo 0
End If
Next
End Function
The function does not recalculate itself, though
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1057404%2fexcel-how-to-sum-all-cells-with-the-same-name%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can write in the summary sheet 2 columns for each invoice write the name of the sheet
Invoice Total
Sheet1
Sheet2
Sheet7
if sheet1 is in A2, in the second column :
=INDIRECT(A2&"!"&"total")
you will have the value of total invoice then you can add it for Grand Total
add a comment |
You can write in the summary sheet 2 columns for each invoice write the name of the sheet
Invoice Total
Sheet1
Sheet2
Sheet7
if sheet1 is in A2, in the second column :
=INDIRECT(A2&"!"&"total")
you will have the value of total invoice then you can add it for Grand Total
add a comment |
You can write in the summary sheet 2 columns for each invoice write the name of the sheet
Invoice Total
Sheet1
Sheet2
Sheet7
if sheet1 is in A2, in the second column :
=INDIRECT(A2&"!"&"total")
you will have the value of total invoice then you can add it for Grand Total
You can write in the summary sheet 2 columns for each invoice write the name of the sheet
Invoice Total
Sheet1
Sheet2
Sheet7
if sheet1 is in A2, in the second column :
=INDIRECT(A2&"!"&"total")
you will have the value of total invoice then you can add it for Grand Total
answered Mar 29 '16 at 14:50
user555689
add a comment |
add a comment |
Old question, but maybe it helps someone with the same problem. I had the same issue and wrote a function for it:
Public Function SumNamedRanges(nm As String) As Double
Dim sh As Worksheet
Dim test As Range
For Each sh In Sheets
' check if the named range exists
On Error Resume Next
Set test = sh.Range(nm)
If Err.Number = 0 Then
On Error GoTo 0
' sum the ranges
SumNamedRanges = SumNamedRanges + _
Application.WorksheetFunction.Sum(test)
Else
On Error GoTo 0
End If
Next
End Function
The function does not recalculate itself, though
add a comment |
Old question, but maybe it helps someone with the same problem. I had the same issue and wrote a function for it:
Public Function SumNamedRanges(nm As String) As Double
Dim sh As Worksheet
Dim test As Range
For Each sh In Sheets
' check if the named range exists
On Error Resume Next
Set test = sh.Range(nm)
If Err.Number = 0 Then
On Error GoTo 0
' sum the ranges
SumNamedRanges = SumNamedRanges + _
Application.WorksheetFunction.Sum(test)
Else
On Error GoTo 0
End If
Next
End Function
The function does not recalculate itself, though
add a comment |
Old question, but maybe it helps someone with the same problem. I had the same issue and wrote a function for it:
Public Function SumNamedRanges(nm As String) As Double
Dim sh As Worksheet
Dim test As Range
For Each sh In Sheets
' check if the named range exists
On Error Resume Next
Set test = sh.Range(nm)
If Err.Number = 0 Then
On Error GoTo 0
' sum the ranges
SumNamedRanges = SumNamedRanges + _
Application.WorksheetFunction.Sum(test)
Else
On Error GoTo 0
End If
Next
End Function
The function does not recalculate itself, though
Old question, but maybe it helps someone with the same problem. I had the same issue and wrote a function for it:
Public Function SumNamedRanges(nm As String) As Double
Dim sh As Worksheet
Dim test As Range
For Each sh In Sheets
' check if the named range exists
On Error Resume Next
Set test = sh.Range(nm)
If Err.Number = 0 Then
On Error GoTo 0
' sum the ranges
SumNamedRanges = SumNamedRanges + _
Application.WorksheetFunction.Sum(test)
Else
On Error GoTo 0
End If
Next
End Function
The function does not recalculate itself, though
edited Jan 25 at 12:52
answered Jan 24 at 17:08
JoostJoost
6027
6027
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1057404%2fexcel-how-to-sum-all-cells-with-the-same-name%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.
– DavidPostill♦
Mar 25 '16 at 23:26
In the first place, how did you give the same name to ranges in different sheet? I'm on Excel 2016 and I'm unable to replicate your situation
– Prasanna
Mar 26 '16 at 1:21
Prasanna - Excel has two levels of named ranges, workbook level, and worksheet level. Here's one way to change it: Start with a single blank sheet. Name your ranges; these will most likely be workbook level ranges by default. Now right-click the sheet tab and copy to a new sheet. The new sheet will have worksheet level ranges. Delete the original sheet. If you continue to make copies of the sheet they will be worksheet level named ranges.
– Dickie Dunkin
Mar 27 '16 at 14:08
Regarding your example with the
Formulas
named range to shade cells with a formula: The formula you've given does not work as a named range on which you can perform functions. It returns eitherTRUE
orFALSE
depending on whether or not a particular cell has a formula in it. If you use it for conditional formatting and apply it to a large range, it will evaluate each cell individually.– Engineer Toast
Mar 28 '16 at 20:45
To learn more about
Get.Cell
, take a look here– Engineer Toast
Mar 28 '16 at 20:46