Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Auto Calculate SUM formula in Table

4,327 views
Skip to first unread message

Dax Arroway

unread,
Mar 12, 2010, 1:28:10 PM3/12/10
to
I have a blank table (not form) with headers which gets filled in, row by
row, as transactions occur. I'm trying to SUM one of the columns (simple SUM
function). I'm trying { SUM(ABOVE) } which works if the table is already
filled out. But if it's blank and gets filled in, the SUM does not calculate
or update automatically. I'd like it to keep a running tally. I've also
tried { SUM(F2:F17) } excel-like code for the cells of the table I'm trying
to SUM but I get the same results; it only adds information already there.
I'd like it to function like excel does, auto updating as the numbers get
entered. Are there field codes or another way to write this to get it to
happen in a Word03 table?
Thanks in advance,
Dax
--
I would give my left hand to be ambidextrous!

Dax Arroway

unread,
Mar 12, 2010, 1:50:01 PM3/12/10
to
Of course I meant: { =SUM(ABOVE) } and I'm using F9 to insert the curly
brackets not just typing them in. (fingers just type too darn FAST!) *blush*

--
I would give my left hand to be ambidextrous!

Doug Robbins - Word MVP

unread,
Mar 12, 2010, 4:42:31 PM3/12/10
to

Insert an Excel spreadsheet into the document in place of the table

--
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

"Dax Arroway" <DaxAr...@discussions.microsoft.com> wrote in message
news:BB9E7641-7EA9-4B27...@microsoft.com...

macropod

unread,
Mar 12, 2010, 10:11:58 PM3/12/10
to
Hi Dax,

Although Word formulae do calculate automatically, they only do so dynamically in documents using formfields with the 'calculate on
exit' option checked. To get the SUM to update in an ordinary document, you'll need to select that cell and press F9. Alternatively,
do a Print Preview.

--
Cheers
macropod
[Microsoft MVP - Word]


"Dax Arroway" <DaxAr...@discussions.microsoft.com> wrote in message news:BB9E7641-7EA9-4B27...@microsoft.com...

Stefan Blom

unread,
Mar 15, 2010, 3:19:43 PM3/15/10
to
Note that although switching to Print Preview updates many fields, it
doesn't update formula fields (not even if the option to update fields
before printing is selected in Word Options).

--
Stefan Blom
Microsoft Word MVP

"macropod" <macr...@invalid.invalid> wrote in message
news:eNYWkrlw...@TK2MSFTNGP06.phx.gbl...

stephen...@rightster.com

unread,
Jul 15, 2014, 8:47:29 AM7/15/14
to
You can do an auto field update for tables within a Word document by using a little bit of VBA. The process is fairly simple:

1. Press Alt + F11 to get to the VBA Window.
2. In the left panel right-click on your document name and select Insert > Class Module. The name will default to Class1 if no other Class Modules are present which is fine.
3. Add the following code in the main window for this new class module:

Public WithEvents App As Word.Application


Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
ActiveDocument.Fields.Update
End Sub

4. Again in the left panel right-click on document name and select Insert > Module and add this code to the main window:

Dim MyWord As New Class1

Sub Register_Event_Handler()
Set MyWord.App = Word.Application
End Sub


Sub AutoOpen()
Register_Event_Handler
End Sub


5. Save the file at a .docm and open the file. Any fields you now modify will fire any calculations in the table.

One last point is that if you want to use this code within a template file you have to add the above code to the normal.dotm file (search for the file location with Windows Explorer) in the same fashion as shown above. The only change you will need to make is to substitute the phrase 'AutoOpen' with 'AutoNew' in step 4.

Hope this helps a few people. Know Microsoft removed the auto update functionality since Word 2002 to aid processing speed, but think they should definitely at least give you the option to this as a normal process within the latest versions of Word given the processing capabilities of most PC's these days.

shaunf...@gmail.com

unread,
Jul 3, 2018, 7:12:17 AM7/3/18
to
This code needs overhauled! it adds the fields everytime an update is made instead of adding the number in the fields only when a change to that field has changed.
0 new messages