• Table calculations with bookmarks

    Author
    Topic
    #464279

    I hope someone can help me with the following problem.

    I have a table that has a couple of subtotals. I have split the table and subtotals into different tables for each section and applied bookmarks to all sections. I have applied a bookmark called Table1 to the first table, Table2 etc. I have called the subtotal rows st1, st2 etc (I have not used these as yet in my calculation) – See attached document.

    I have managed to get the formulas for each section to work but I cannot find any information on what to add in this formula if a section is deleted. Eg if the table inside the Table2 bookmark is deleted what would add to the formula so that the bookmark will be ignored and not return the error !Undefined bookmark, TABLE 2.

    Inside the field I have the following:
    { =SUM(Table1 B:B)-SUM(Table2 B:B)-SUM(Table3 B:B)-SUM(Table4 B:B) # “$#,##0.00” }

    I found a very good document on this site on Word Field Maths which helped me up to this point but countless searches on google does not bring any results for this type of query.

    I have no knowledge of vba so I cannot use vba to fix this problem.

    Any help would be greatly appreciated.

    Viewing 4 reply threads
    Author
    Replies
    • #1187774

      You can test for the error using an IF field. I’m not much of a field whiz, but this works for me.

        [*]Press Alt+F9 to toggle the display to field codes (instead of field results)
        [*]Select you existing field and press Ctrl+F9 to surround it with a new field
        [*]Just inside the new opening field brace, type IF and then press Ctrl+F9 again
        [*]Inside the new new opening field brace, type REF “Tablex” (where Tablex is the bookmarks you want to test for)
        [*]Just after the corresponding closing field brace, paste the following =”Error! Reference source not found.”
        [*]Type a space and then type “-“ (you can change this later, but this will help with debugging)
        [*]Make sure there is a space before the opening field brace for the “real” result
        [*]Press Alt+F9 to toggle the display to field results

      Now you can test by adding or removing the bookmark and refreshing the IF field.

      It’s a lot of edits. For the second and subsequent, you can shortcut the process by creating the outer field code and pasting from the IF through the “-” and then editing the bookmark.

      Any luck? (I’m sure someone will have a more efficient suggestion…)

    • #1187806

      I’d use Excel for this – it is much more suitable for formulas.

    • #1188345

      Thanks Jscher. I tried your method and all I got was a dash. Not sure if I did this right but I want users to be able to delete rows if need be.

      I cannot use Excel for this as the client copies this table out of the letter sent into another document and specifies word format.

      I will just have to tell all the users of this document not to delete any rows.

      Thank you for your responses.

      • #1188350

        Thanks Jscher. I tried your method and all I got was a dash. Not sure if I did this right but I want users to be able to delete rows if need be.

        The dash shows that the formula recognized a missing bookmark. Change the dash to whatever you like: it can be blank or it can be a note to the user, such as, “You can delete this row now.” However, as far as I know, there’s no way to wrap the entire table row in a field, so you can’t completely suppress it if the user removes a bookmark.

    • #1188368

      That makes sense now. Thanks

    • #1976706

      I am trying to create a formula in Word that will compare the sum of two bookmarks with a number (limit) and return the limit if the sum of the two other bookmarks is greater than the limit. If the sum is less than the limit, I need it to return the sum. I have tried so many combinations, that they are all starting to look the same. I either get a syntax error message, or I get an unexpected end of the formula message.

      Bookmark#1 = $3,301,390.48

      Bookmark#2 = $11,923,900.00

      Sum = $15,225,290.48

      Limit = $15,000,000.00 (this is also a bookmark)

      I can get the two bookmarks to sum, or I can get the limit to show, but changing the bookmark numbers gives me an error message above.

    Viewing 4 reply threads
    Reply To: Table calculations with bookmarks

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: