A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Formula in Word Table



 
 
Thread Tools Display Modes
  #1  
Old May 12th 09, 08:07 AM posted to microsoft.public.word.tables
Stuart Mattinson
external usenet poster
 
Posts: 1
Default Formula in Word Table

I am trying to create a formula that will span multipule tables, I am running
a merge option that will create duplicate tables within a word document with
the following formula at the end of each table =sum(b3)+(b4)+(b5).

My problem comes in that I never know how many tables will be created and I
need to add all of these totals together from each table to create a Grand
Total.

What formula would I use to add all the tables together, the cell that I
would need to add in each table is b6
Ads
  #2  
Old May 12th 09, 08:35 AM posted to microsoft.public.word.tables
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,832
Default Formula in Word Table

I would use a macro containing the following code:

Dim i As Long, total As Double
Dim rsum As Range
total = 0
With ActiveDocument
For i = 1 To .Tables.Count
Set rsum = .Tables(i).Cell(6, 2).Range
rsum.End = rsum.End - 1
If IsNumeric(rsum.Text) Then
total = total + rsum.Text
End If
Next i
End With
MsgBox "The total of all cells B6 is " & total


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Stuart Mattinson" Stuart wrote in
message ...
I am trying to create a formula that will span multipule tables, I am
running
a merge option that will create duplicate tables within a word document
with
the following formula at the end of each table =sum(b3)+(b4)+(b5).

My problem comes in that I never know how many tables will be created and
I
need to add all of these totals together from each table to create a Grand
Total.

What formula would I use to add all the tables together, the cell that I
would need to add in each table is b6


  #3  
Old May 12th 09, 10:11 AM posted to microsoft.public.word.tables
Stuart Mattinson[_2_]
external usenet poster
 
Posts: 3
Default Formula in Word Table

Dear Doug,

Thanks for the Macro, would it possible to make the macro automatically
place the Words "Grand Total" and the calculated amount after the last table
rather than a message box

As it is a macro should I create a shortcut key for the users to press when
they want to run it as it should only be run after the merge?

"Doug Robbins - Word MVP" wrote:

I would use a macro containing the following code:

Dim i As Long, total As Double
Dim rsum As Range
total = 0
With ActiveDocument
For i = 1 To .Tables.Count
Set rsum = .Tables(i).Cell(6, 2).Range
rsum.End = rsum.End - 1
If IsNumeric(rsum.Text) Then
total = total + rsum.Text
End If
Next i
End With
MsgBox "The total of all cells B6 is " & total


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Stuart Mattinson" Stuart wrote in
message ...
I am trying to create a formula that will span multipule tables, I am
running
a merge option that will create duplicate tables within a word document
with
the following formula at the end of each table =sum(b3)+(b4)+(b5).

My problem comes in that I never know how many tables will be created and
I
need to add all of these totals together from each table to create a Grand
Total.

What formula would I use to add all the tables together, the cell that I
would need to add in each table is b6



  #4  
Old May 12th 09, 03:09 PM posted to microsoft.public.word.tables
Stuart Mattinson[_2_]
external usenet poster
 
Posts: 3
Default Formula in Word Table

I was able to add the amount in by adding a bookmark and the following lines

ActiveDocument.Bookmarks("GrandTotal").Select
Selection = "R" & total

I was not able to force the decimal place to be 2 characters only though, so
will keep on wotking on that


"Stuart Mattinson" wrote:

Dear Doug,

Thanks for the Macro, would it possible to make the macro automatically
place the Words "Grand Total" and the calculated amount after the last table
rather than a message box

As it is a macro should I create a shortcut key for the users to press when
they want to run it as it should only be run after the merge?

"Doug Robbins - Word MVP" wrote:

I would use a macro containing the following code:

Dim i As Long, total As Double
Dim rsum As Range
total = 0
With ActiveDocument
For i = 1 To .Tables.Count
Set rsum = .Tables(i).Cell(6, 2).Range
rsum.End = rsum.End - 1
If IsNumeric(rsum.Text) Then
total = total + rsum.Text
End If
Next i
End With
MsgBox "The total of all cells B6 is " & total


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Stuart Mattinson" Stuart wrote in
message ...
I am trying to create a formula that will span multipule tables, I am
running
a merge option that will create duplicate tables within a word document
with
the following formula at the end of each table =sum(b3)+(b4)+(b5).

My problem comes in that I never know how many tables will be created and
I
need to add all of these totals together from each table to create a Grand
Total.

What formula would I use to add all the tables together, the cell that I
would need to add in each table is b6



  #5  
Old May 12th 09, 09:51 PM posted to microsoft.public.word.tables
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,832
Default Formula in Word Table

Use Format(total, "#,###.00")

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Stuart Mattinson" wrote in
message news
I was able to add the amount in by adding a bookmark and the following
lines

ActiveDocument.Bookmarks("GrandTotal").Select
Selection = "R" & total

I was not able to force the decimal place to be 2 characters only though,
so
will keep on wotking on that


"Stuart Mattinson" wrote:

Dear Doug,

Thanks for the Macro, would it possible to make the macro automatically
place the Words "Grand Total" and the calculated amount after the last
table
rather than a message box

As it is a macro should I create a shortcut key for the users to press
when
they want to run it as it should only be run after the merge?

"Doug Robbins - Word MVP" wrote:

I would use a macro containing the following code:

Dim i As Long, total As Double
Dim rsum As Range
total = 0
With ActiveDocument
For i = 1 To .Tables.Count
Set rsum = .Tables(i).Cell(6, 2).Range
rsum.End = rsum.End - 1
If IsNumeric(rsum.Text) Then
total = total + rsum.Text
End If
Next i
End With
MsgBox "The total of all cells B6 is " & total


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Stuart Mattinson" Stuart wrote
in
message ...
I am trying to create a formula that will span multipule tables, I am
running
a merge option that will create duplicate tables within a word
document
with
the following formula at the end of each table =sum(b3)+(b4)+(b5).

My problem comes in that I never know how many tables will be created
and
I
need to add all of these totals together from each table to create a
Grand
Total.

What formula would I use to add all the tables together, the cell
that I
would need to add in each table is b6



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Table Formula Jseakin Tables 1 April 23rd 09 08:48 PM
Excel Formula to Word Table setoFairfax Tables 1 November 21st 07 04:11 AM
Can word do this formula =EXP(B2) in a table? GT Tables 1 August 8th 07 01:43 AM
how do I get this formula (A2*d2)-e2 in a word table Big dogs Tables 2 April 22nd 06 12:03 PM
How do I set up a formula in a table in Word? Kathleen Tables 2 November 1st 05 08:49 AM


All times are GMT +1. The time now is 11:10 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.