Programming Methods : Caculations In A Table

D

De Vo

Hi

I wonder if people can discuss with me "the better technique" on the
way to program the following scenario

I have a table where calculation will be performed

Column Headings of

Employee Name; Gross Pay; Tax / Vat %; Nett Wages;

The Tax / VAT % will be a positive or negative percentage figure
usually -22% or +17.5%

The main part of the problem is how to create the caculation and the
best method (in the long run even if it more complex and will take a
longer time to grasp and fine tune)

I can see that there is the method of placing a dynamic formula in each
Nett Wages cell and then recalculate the table

or

there is the way of reading the data from the cell and dynamically
caculating the Nett Wages for each row and outputting the answer.

Whats is the best method to be using

If it method (b) how do i read data from the cells and anything i need
to watch out for to caculate the data,


Many Thanks

De Vo
 
W

Word Heretic

G'day Devo,

First, is how to trigger the update. If you want to use VBA then you
will need some device like a macro button field to actually invoke the
formatting. Update Now! might be suitable after the table.

If you then must print the document, you need a Print Me! button that
then hides all macrobuttons. Getting messy yet?

Reading the cells is easy enough, you can extend the selection
backwards and work with

With Selection.Range.Tables
With .Item(.Count)

With .range.cells

or

With .Rows



strip the last two chars from any cell and you have the cell contents.
You can Val() this or convert to other datatypes as necc.

Inserting then collapses the insert range in the relevant cell and
does a .insertafter

Thus dynamic fields are preferable IF you can get away with them.

Steve Hudson - Word Heretic Sydney Australia
Word eTutor

steve from wordheretic.com (Email replies require payment)


De Vo reckoned:
 
M

macropod

Hi De Vo,

Assuming your gross pay is in B2 and the VAT is in C2, you could do the calc
with a Word field: {=b2*(1+c2)}

If you also want to be able to have this formula automatically take count of
changing row numbers in the table, see my reply of 14/2 to "REPEATING
FORMULAS IN WORD XP" in the word.tables newsgroup.

Then, if any of the values change, a simple line:
ActiveDocument.Fields.Update
in a macro will update all the fields in the body of the document.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top