SUM in word table with Variable cells
up vote
1
down vote
favorite
I have a table in the Word program like the following:
By opening this table file, I have to increase or decrease the number of rows. So I can not use the formula for the sum of the seasons (Because cell numbers change). In your opinion, how can I sum up the values of "Total Season 1" and "Total Season 2" and put it in "Total Seasons"?
Do you think Can I get help of the words "Total Season" or choosing the Bold words with VBA?
microsoft-word vba
New contributor
add a comment |
up vote
1
down vote
favorite
I have a table in the Word program like the following:
By opening this table file, I have to increase or decrease the number of rows. So I can not use the formula for the sum of the seasons (Because cell numbers change). In your opinion, how can I sum up the values of "Total Season 1" and "Total Season 2" and put it in "Total Seasons"?
Do you think Can I get help of the words "Total Season" or choosing the Bold words with VBA?
microsoft-word vba
New contributor
2
Think about to convert this common Word table to Excel table.
– Akina
Nov 12 at 6:54
Unfortunately I can not run Excel. Do you think the words can not be used?
– First Last
Nov 12 at 6:58
Word is not designed for complex calculations, probably it can't calculate it for you using standard calculations. VBA can be used, however there are also limitations with VBA in Word tables, it's not really straightforward. Asking for code is generally off-topic here as it sounds we need to do your job, it's acceptable only if you demonstrate your own effort to solve the problem (= post code) and ask specific question on how to fix it.
– Máté Juhász
Nov 12 at 7:13
1
I can not run Excel. You do NOT need in Excel. Look Word, Insert pane, Tables tab. Table knob is clickable multi-variant listbox, and one of possible variants is inserting Excel table.
– Akina
Nov 12 at 8:08
1
Quick fix would be to split your table for each season so they are separate - you can make them seem almost same by setting the paragraph spacing for the gap between them to exactly 1pt. In your total cell for each season, select the cell contents (presumably a SUM ABOVE field) and create a bookmark eg bkSeason1Total. Then in your total seasons cell, you can insert a formula field that adds up the 2 bookmarks.
– Tanya
Nov 13 at 21:39
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a table in the Word program like the following:
By opening this table file, I have to increase or decrease the number of rows. So I can not use the formula for the sum of the seasons (Because cell numbers change). In your opinion, how can I sum up the values of "Total Season 1" and "Total Season 2" and put it in "Total Seasons"?
Do you think Can I get help of the words "Total Season" or choosing the Bold words with VBA?
microsoft-word vba
New contributor
I have a table in the Word program like the following:
By opening this table file, I have to increase or decrease the number of rows. So I can not use the formula for the sum of the seasons (Because cell numbers change). In your opinion, how can I sum up the values of "Total Season 1" and "Total Season 2" and put it in "Total Seasons"?
Do you think Can I get help of the words "Total Season" or choosing the Bold words with VBA?
microsoft-word vba
microsoft-word vba
New contributor
New contributor
edited Nov 13 at 11:19
Toto
3,23291125
3,23291125
New contributor
asked Nov 12 at 6:49
First Last
163
163
New contributor
New contributor
2
Think about to convert this common Word table to Excel table.
– Akina
Nov 12 at 6:54
Unfortunately I can not run Excel. Do you think the words can not be used?
– First Last
Nov 12 at 6:58
Word is not designed for complex calculations, probably it can't calculate it for you using standard calculations. VBA can be used, however there are also limitations with VBA in Word tables, it's not really straightforward. Asking for code is generally off-topic here as it sounds we need to do your job, it's acceptable only if you demonstrate your own effort to solve the problem (= post code) and ask specific question on how to fix it.
– Máté Juhász
Nov 12 at 7:13
1
I can not run Excel. You do NOT need in Excel. Look Word, Insert pane, Tables tab. Table knob is clickable multi-variant listbox, and one of possible variants is inserting Excel table.
– Akina
Nov 12 at 8:08
1
Quick fix would be to split your table for each season so they are separate - you can make them seem almost same by setting the paragraph spacing for the gap between them to exactly 1pt. In your total cell for each season, select the cell contents (presumably a SUM ABOVE field) and create a bookmark eg bkSeason1Total. Then in your total seasons cell, you can insert a formula field that adds up the 2 bookmarks.
– Tanya
Nov 13 at 21:39
add a comment |
2
Think about to convert this common Word table to Excel table.
– Akina
Nov 12 at 6:54
Unfortunately I can not run Excel. Do you think the words can not be used?
– First Last
Nov 12 at 6:58
Word is not designed for complex calculations, probably it can't calculate it for you using standard calculations. VBA can be used, however there are also limitations with VBA in Word tables, it's not really straightforward. Asking for code is generally off-topic here as it sounds we need to do your job, it's acceptable only if you demonstrate your own effort to solve the problem (= post code) and ask specific question on how to fix it.
– Máté Juhász
Nov 12 at 7:13
1
I can not run Excel. You do NOT need in Excel. Look Word, Insert pane, Tables tab. Table knob is clickable multi-variant listbox, and one of possible variants is inserting Excel table.
– Akina
Nov 12 at 8:08
1
Quick fix would be to split your table for each season so they are separate - you can make them seem almost same by setting the paragraph spacing for the gap between them to exactly 1pt. In your total cell for each season, select the cell contents (presumably a SUM ABOVE field) and create a bookmark eg bkSeason1Total. Then in your total seasons cell, you can insert a formula field that adds up the 2 bookmarks.
– Tanya
Nov 13 at 21:39
2
2
Think about to convert this common Word table to Excel table.
– Akina
Nov 12 at 6:54
Think about to convert this common Word table to Excel table.
– Akina
Nov 12 at 6:54
Unfortunately I can not run Excel. Do you think the words can not be used?
– First Last
Nov 12 at 6:58
Unfortunately I can not run Excel. Do you think the words can not be used?
– First Last
Nov 12 at 6:58
Word is not designed for complex calculations, probably it can't calculate it for you using standard calculations. VBA can be used, however there are also limitations with VBA in Word tables, it's not really straightforward. Asking for code is generally off-topic here as it sounds we need to do your job, it's acceptable only if you demonstrate your own effort to solve the problem (= post code) and ask specific question on how to fix it.
– Máté Juhász
Nov 12 at 7:13
Word is not designed for complex calculations, probably it can't calculate it for you using standard calculations. VBA can be used, however there are also limitations with VBA in Word tables, it's not really straightforward. Asking for code is generally off-topic here as it sounds we need to do your job, it's acceptable only if you demonstrate your own effort to solve the problem (= post code) and ask specific question on how to fix it.
– Máté Juhász
Nov 12 at 7:13
1
1
I can not run Excel. You do NOT need in Excel. Look Word, Insert pane, Tables tab. Table knob is clickable multi-variant listbox, and one of possible variants is inserting Excel table.
– Akina
Nov 12 at 8:08
I can not run Excel. You do NOT need in Excel. Look Word, Insert pane, Tables tab. Table knob is clickable multi-variant listbox, and one of possible variants is inserting Excel table.
– Akina
Nov 12 at 8:08
1
1
Quick fix would be to split your table for each season so they are separate - you can make them seem almost same by setting the paragraph spacing for the gap between them to exactly 1pt. In your total cell for each season, select the cell contents (presumably a SUM ABOVE field) and create a bookmark eg bkSeason1Total. Then in your total seasons cell, you can insert a formula field that adds up the 2 bookmarks.
– Tanya
Nov 13 at 21:39
Quick fix would be to split your table for each season so they are separate - you can make them seem almost same by setting the paragraph spacing for the gap between them to exactly 1pt. In your total cell for each season, select the cell contents (presumably a SUM ABOVE field) and create a bookmark eg bkSeason1Total. Then in your total seasons cell, you can insert a formula field that adds up the 2 bookmarks.
– Tanya
Nov 13 at 21:39
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
Hello dear friends who tried to help me! I worked on this topic the same day and I managed to solve the problem by writing the following code. I put this code here for everyone. If friends are willing, they can provide better codes for easier and faster running. be happy...
Sub CalculatingTotalSeasons()
ActiveDocument.Tables(1).Select
Selection.Copy
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
Selection.PasteAndFormat (wdFormatOriginalFormatting)
Dim t As Table
Dim r As Row
Dim ts As String
Set t = ActiveDocument.Tables(2)
ts = "Total Season"
For Each r In t.Rows
If Left(r.Cells(1).Range.Text, 12) <> ts Then r.Delete
Next r
With ActiveDocument.Tables(2)
ActiveDocument.Tables(2).Cell(1, 1).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total Seasons"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.InsertFormula Formula:="=SUM(ABOVE)", NumberFormat:=""
Selection.MoveLeft Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.Copy
ActiveDocument.Tables(2).Delete
End With
ActiveDocument.Tables(1).Select
With ActiveDocument.Tables(1)
ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total Seasons"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.PasteAndFormat (wdFormatPlainText)
End With
End Sub
New contributor
add a comment |
up vote
0
down vote
To make a table in Word perform some automatic summation of values there are formatting steps you have to take. Below is an example of what you might want the final result to look like.
The shaded values in the image below are created from formula fields. In order for the "=SUM(ABOVE)" formula to work in the Subtotal rows, there must be a blank row or a non-numeric cell between the parts of the table. The red arrows point to the inserted blank rows. I have made them very narrow so they look like just a line separator, but in fact they are actually a blank row.
In order to calculate the Grand Total, which is a sum of the two Subtotals, each Subtotal formula is enclosed within a bookmark. For this example they are named Materials and Services.
The field formulas are shown in the image below. They include the code needed for formatting.
To update the table after adding new data rows, you select the table and then press F9.
Hi dear friend @Rich Michaels! thank you. I have read your article. But it seems a bit long way. In the answer section, I put a code that does not need to add an empty line and the bookmarks. Good luck.
– First Last
19 hours ago
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Hello dear friends who tried to help me! I worked on this topic the same day and I managed to solve the problem by writing the following code. I put this code here for everyone. If friends are willing, they can provide better codes for easier and faster running. be happy...
Sub CalculatingTotalSeasons()
ActiveDocument.Tables(1).Select
Selection.Copy
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
Selection.PasteAndFormat (wdFormatOriginalFormatting)
Dim t As Table
Dim r As Row
Dim ts As String
Set t = ActiveDocument.Tables(2)
ts = "Total Season"
For Each r In t.Rows
If Left(r.Cells(1).Range.Text, 12) <> ts Then r.Delete
Next r
With ActiveDocument.Tables(2)
ActiveDocument.Tables(2).Cell(1, 1).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total Seasons"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.InsertFormula Formula:="=SUM(ABOVE)", NumberFormat:=""
Selection.MoveLeft Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.Copy
ActiveDocument.Tables(2).Delete
End With
ActiveDocument.Tables(1).Select
With ActiveDocument.Tables(1)
ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total Seasons"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.PasteAndFormat (wdFormatPlainText)
End With
End Sub
New contributor
add a comment |
up vote
1
down vote
Hello dear friends who tried to help me! I worked on this topic the same day and I managed to solve the problem by writing the following code. I put this code here for everyone. If friends are willing, they can provide better codes for easier and faster running. be happy...
Sub CalculatingTotalSeasons()
ActiveDocument.Tables(1).Select
Selection.Copy
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
Selection.PasteAndFormat (wdFormatOriginalFormatting)
Dim t As Table
Dim r As Row
Dim ts As String
Set t = ActiveDocument.Tables(2)
ts = "Total Season"
For Each r In t.Rows
If Left(r.Cells(1).Range.Text, 12) <> ts Then r.Delete
Next r
With ActiveDocument.Tables(2)
ActiveDocument.Tables(2).Cell(1, 1).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total Seasons"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.InsertFormula Formula:="=SUM(ABOVE)", NumberFormat:=""
Selection.MoveLeft Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.Copy
ActiveDocument.Tables(2).Delete
End With
ActiveDocument.Tables(1).Select
With ActiveDocument.Tables(1)
ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total Seasons"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.PasteAndFormat (wdFormatPlainText)
End With
End Sub
New contributor
add a comment |
up vote
1
down vote
up vote
1
down vote
Hello dear friends who tried to help me! I worked on this topic the same day and I managed to solve the problem by writing the following code. I put this code here for everyone. If friends are willing, they can provide better codes for easier and faster running. be happy...
Sub CalculatingTotalSeasons()
ActiveDocument.Tables(1).Select
Selection.Copy
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
Selection.PasteAndFormat (wdFormatOriginalFormatting)
Dim t As Table
Dim r As Row
Dim ts As String
Set t = ActiveDocument.Tables(2)
ts = "Total Season"
For Each r In t.Rows
If Left(r.Cells(1).Range.Text, 12) <> ts Then r.Delete
Next r
With ActiveDocument.Tables(2)
ActiveDocument.Tables(2).Cell(1, 1).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total Seasons"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.InsertFormula Formula:="=SUM(ABOVE)", NumberFormat:=""
Selection.MoveLeft Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.Copy
ActiveDocument.Tables(2).Delete
End With
ActiveDocument.Tables(1).Select
With ActiveDocument.Tables(1)
ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total Seasons"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.PasteAndFormat (wdFormatPlainText)
End With
End Sub
New contributor
Hello dear friends who tried to help me! I worked on this topic the same day and I managed to solve the problem by writing the following code. I put this code here for everyone. If friends are willing, they can provide better codes for easier and faster running. be happy...
Sub CalculatingTotalSeasons()
ActiveDocument.Tables(1).Select
Selection.Copy
Selection.EndKey Unit:=wdStory
Selection.TypeParagraph
Selection.PasteAndFormat (wdFormatOriginalFormatting)
Dim t As Table
Dim r As Row
Dim ts As String
Set t = ActiveDocument.Tables(2)
ts = "Total Season"
For Each r In t.Rows
If Left(r.Cells(1).Range.Text, 12) <> ts Then r.Delete
Next r
With ActiveDocument.Tables(2)
ActiveDocument.Tables(2).Cell(1, 1).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total Seasons"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.InsertFormula Formula:="=SUM(ABOVE)", NumberFormat:=""
Selection.MoveLeft Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.Copy
ActiveDocument.Tables(2).Delete
End With
ActiveDocument.Tables(1).Select
With ActiveDocument.Tables(1)
ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Total Seasons"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.PasteAndFormat (wdFormatPlainText)
End With
End Sub
New contributor
New contributor
answered 19 hours ago
First Last
163
163
New contributor
New contributor
add a comment |
add a comment |
up vote
0
down vote
To make a table in Word perform some automatic summation of values there are formatting steps you have to take. Below is an example of what you might want the final result to look like.
The shaded values in the image below are created from formula fields. In order for the "=SUM(ABOVE)" formula to work in the Subtotal rows, there must be a blank row or a non-numeric cell between the parts of the table. The red arrows point to the inserted blank rows. I have made them very narrow so they look like just a line separator, but in fact they are actually a blank row.
In order to calculate the Grand Total, which is a sum of the two Subtotals, each Subtotal formula is enclosed within a bookmark. For this example they are named Materials and Services.
The field formulas are shown in the image below. They include the code needed for formatting.
To update the table after adding new data rows, you select the table and then press F9.
Hi dear friend @Rich Michaels! thank you. I have read your article. But it seems a bit long way. In the answer section, I put a code that does not need to add an empty line and the bookmarks. Good luck.
– First Last
19 hours ago
add a comment |
up vote
0
down vote
To make a table in Word perform some automatic summation of values there are formatting steps you have to take. Below is an example of what you might want the final result to look like.
The shaded values in the image below are created from formula fields. In order for the "=SUM(ABOVE)" formula to work in the Subtotal rows, there must be a blank row or a non-numeric cell between the parts of the table. The red arrows point to the inserted blank rows. I have made them very narrow so they look like just a line separator, but in fact they are actually a blank row.
In order to calculate the Grand Total, which is a sum of the two Subtotals, each Subtotal formula is enclosed within a bookmark. For this example they are named Materials and Services.
The field formulas are shown in the image below. They include the code needed for formatting.
To update the table after adding new data rows, you select the table and then press F9.
Hi dear friend @Rich Michaels! thank you. I have read your article. But it seems a bit long way. In the answer section, I put a code that does not need to add an empty line and the bookmarks. Good luck.
– First Last
19 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
To make a table in Word perform some automatic summation of values there are formatting steps you have to take. Below is an example of what you might want the final result to look like.
The shaded values in the image below are created from formula fields. In order for the "=SUM(ABOVE)" formula to work in the Subtotal rows, there must be a blank row or a non-numeric cell between the parts of the table. The red arrows point to the inserted blank rows. I have made them very narrow so they look like just a line separator, but in fact they are actually a blank row.
In order to calculate the Grand Total, which is a sum of the two Subtotals, each Subtotal formula is enclosed within a bookmark. For this example they are named Materials and Services.
The field formulas are shown in the image below. They include the code needed for formatting.
To update the table after adding new data rows, you select the table and then press F9.
To make a table in Word perform some automatic summation of values there are formatting steps you have to take. Below is an example of what you might want the final result to look like.
The shaded values in the image below are created from formula fields. In order for the "=SUM(ABOVE)" formula to work in the Subtotal rows, there must be a blank row or a non-numeric cell between the parts of the table. The red arrows point to the inserted blank rows. I have made them very narrow so they look like just a line separator, but in fact they are actually a blank row.
In order to calculate the Grand Total, which is a sum of the two Subtotals, each Subtotal formula is enclosed within a bookmark. For this example they are named Materials and Services.
The field formulas are shown in the image below. They include the code needed for formatting.
To update the table after adding new data rows, you select the table and then press F9.
answered 2 days ago
Rich Michaels
1,0192210
1,0192210
Hi dear friend @Rich Michaels! thank you. I have read your article. But it seems a bit long way. In the answer section, I put a code that does not need to add an empty line and the bookmarks. Good luck.
– First Last
19 hours ago
add a comment |
Hi dear friend @Rich Michaels! thank you. I have read your article. But it seems a bit long way. In the answer section, I put a code that does not need to add an empty line and the bookmarks. Good luck.
– First Last
19 hours ago
Hi dear friend @Rich Michaels! thank you. I have read your article. But it seems a bit long way. In the answer section, I put a code that does not need to add an empty line and the bookmarks. Good luck.
– First Last
19 hours ago
Hi dear friend @Rich Michaels! thank you. I have read your article. But it seems a bit long way. In the answer section, I put a code that does not need to add an empty line and the bookmarks. Good luck.
– First Last
19 hours ago
add a comment |
First Last is a new contributor. Be nice, and check out our Code of Conduct.
First Last is a new contributor. Be nice, and check out our Code of Conduct.
First Last is a new contributor. Be nice, and check out our Code of Conduct.
First Last is a new contributor. Be nice, and check out our Code of Conduct.
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%2f1374637%2fsum-in-word-table-with-variable-cells%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
2
Think about to convert this common Word table to Excel table.
– Akina
Nov 12 at 6:54
Unfortunately I can not run Excel. Do you think the words can not be used?
– First Last
Nov 12 at 6:58
Word is not designed for complex calculations, probably it can't calculate it for you using standard calculations. VBA can be used, however there are also limitations with VBA in Word tables, it's not really straightforward. Asking for code is generally off-topic here as it sounds we need to do your job, it's acceptable only if you demonstrate your own effort to solve the problem (= post code) and ask specific question on how to fix it.
– Máté Juhász
Nov 12 at 7:13
1
I can not run Excel. You do NOT need in Excel. Look Word, Insert pane, Tables tab. Table knob is clickable multi-variant listbox, and one of possible variants is inserting Excel table.
– Akina
Nov 12 at 8:08
1
Quick fix would be to split your table for each season so they are separate - you can make them seem almost same by setting the paragraph spacing for the gap between them to exactly 1pt. In your total cell for each season, select the cell contents (presumably a SUM ABOVE field) and create a bookmark eg bkSeason1Total. Then in your total seasons cell, you can insert a formula field that adds up the 2 bookmarks.
– Tanya
Nov 13 at 21:39