Question

I have a Word document with a large timetable in it, n rows with each row relating to an activity during a day. I Have assigned each activity a duration D (in minutes) in one column of the table, and an activity start time T, where T(N+1) = T(N)+D(N):

Name      | Time  | Duration
Activity1 | 09:00 | 5
Activity2 | 09:05 | 10
Activity3 | 09:15 | ...

I'd like the Time Column to be a series of formulas such that they update the whole table correctly if I change the start time or the duration, add or remove a row.

At the moment I'm exporting the list to excel each time to do the calculation, an I do not want to embed a worksheet because of pressure not to change the table from the document's creator.

Is there a way to do this in word?

Was it helpful?

Solution

wrt my comment about row insertion, you could do this using the following field codes.

Let's suppose the Time is in column B, the initial time is in B2, and the Durations are just numbers of minutes types in Column C.

Then in B2 you have the following fields. To set the initial time, the user would have to display the fields and modify the time in the { SET s } field. Or you could use an ASK field instead.

{ SET s "09:15" }{ SET m { ={ref s \@HH }*60+{ref s \@mm } } }{ SEQ r \r2 \h }{ SET t1 "mod(int((m+SUM(C{ SEQ r \c }:C" }{ SET t2 "))/60),24)*100+mod(m+SUM(C{ SEQ r \c }:C" }{ SET t3 "),60)" }{ref  s }

In B3 and below you would need the following fields:

{ SET c "{ t1 }{ SEQ r \c }{ t2 }{ SEQ r \c }{ t3 }"  }{ SEQ r \h }{ ={ c } \#00:00 }

The time calculation is built up in c and for example in B5 it would be,

mod(int(initial_time_in_minutes+SUM(C2:C5))/60),24)*100+mod(initial_time_in_minutes+SUM(C2:C5),60)

All the {} are the special field code brace pairs that you can enter in Windows Word using ctrl-F9 and the user would have to select the column and press F9 to re-execute the fields. You can eliminate a lot of the spaces in these fields if you prefer. You may need to avoid using bookmark names that look like cell addresses ("t1" etc.)

OTHER TIPS

I eventually settled on a solution much like bibadia's above, without the column referencing:

Fields before the table are:

Set the start hours for the table

{ set th {9}  }

Set the start minutes for the table

{ set tm {15} }

Then in each time cell paste the following fields:

Print the time

{ ref th \# 00 }:{ ref tm \# 00 }

Get the increment from the column to the right and add to the minutes

{ set tm { = SUM(RIGHT, { ref tm }) } }

Strip off any hours from tm and add to the hours (which does not account for 24 roll over like bibadia's does)

{ set th { = SUM ({ ref th }, int({ ref tm }/60)) } }

Get the remaining minutes

{ set tm { = mod({ref tm, 60}) }}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top