PDA

View Full Version : Updating All Formula Fields in a Range of Table Cells



Vestige
03-11-2014, 09:56 PM
I have a simple Word timesheet (I tried to get them to do it in Excel). I'd like to be able to update the time summary fields without updating the date fields. All my other subs work except the range-based field update.

I have pieced together the following subroutine after a few hours of research. I keep getting the "Invalid or unqualified reference" compile error highlighting the first .Tables(2) reference in the range definition.



Sub UpdateTimeFields()
'
' UpdateTimeFields Macro
'
'
Dim TimeCells As Range
Set TimeCells = ActiveDocument.Range(Start:=Tables(2).Cell(3, 3).Range.Start, End:=.Tables(2).Cell(37, 4).Range.End)
Selection.Fields.Update
TimeCells.Select
End Sub


Any help would be appreciated...

Gary

macropod
03-12-2014, 03:29 AM
If you're using formfields for the input, you don't need a macro; simply check the 'calculate on exit' properties for whichever formfields you'd like to use to initiate the calculations. Note that, checking the 'calculate on exit' property for any formfield results in all formula fields being updated, along with any others that might also need updating..