Log in

View Full Version : ROUNDING NUMBERS IN WORD CALCULATIONS



Greg
03-12-2008, 12:18 AM
Hi all,

I want (if possible) to round up the daily rate in my calcualtion from $5.2136 to $5.214. Part of my document is attached.

Also, I want to know if it's possible, and if so by what method, I can add an extra day to the datediff result. In the present example there is 705 days between 7 april 2006 and 13 March 2008. How can I get a result of 706 days?

I hope you can help.

greg.

Tinbendr
03-13-2008, 07:08 PM
I want to round up Use the Round function.

Call FillABookmark("DailyRate", Format(Round((CLng(txtAmount) * CLng(txtRate) _
/ 100 / 365), 3), Application.International(wdCurrencyCode) & "#.####"))



...add an extra day to the datediff result.

Just add one to it. But when I ran the demo, I got 706 days. :think:



Call FillABookmark("NumDays", DateDiff("d", txtStartDate, txtEndDate) + 1)

Greg
03-13-2008, 08:50 PM
Thank you Tinbendr. That works perfectly.

Greg
03-13-2008, 11:06 PM
Actually Tinbendr I have noticed one small glitch with the full form. A copy is attached.

If I change the amount of the claim via the userform and press ok the interest recalculates but the total in the schedule at the end of the document doesn't change at all.

However, if I bring up the userform again and press ok once more, the total field does update. If I don't address this problem I can see it causing major problems. Do you have any idea why I need to press ok twice to update all of the fields?

I hope you can see a solution to this.

Regards,

greg.

Tinbendr
03-14-2008, 06:54 PM
If I added another field update call, it works. (Don't ask me why.)

Also, you can remove the Round as Format will round for you if you shorten the format string by one.

Call MyUpdateFields
Call FillABookmark("DailyRate", Format((CLng(txtAmount) * CLng(txtRate) _
/ 100 / 365), Application.International(wdCurrencyCode) & "#.###"))
Call MyUpdateFields

Greg
03-16-2008, 12:45 AM
Yes, it works very nicely now. Thanks once more.