Help with math needed desperately.

M

Maurene Garza

I need help writing the code to do the following. This is
in Word 2000.

Take the value of "ObDebt", add it to the value
of "AmtBorrow", and insert that sum at a bookmark
named "ObDebtAmtBorrow."

ObDebt and AmtBorrow are numbers typed into a TextBox in a
user form.
 
J

Jonathan West

Maurene Garza said:
I need help writing the code to do the following. This is
in Word 2000.

Take the value of "ObDebt", add it to the value
of "AmtBorrow", and insert that sum at a bookmark
named "ObDebtAmtBorrow."

ObDebt and AmtBorrow are numbers typed into a TextBox in a
user form.

can be done with one (rather long) line

ActiveDocument.Bookmarks("ObDebtAmtBorrow").Range.Insertafter
CStr(Val(BbDebt) + Val(AmtBorrow))

I'm assuming here that ObDebt and AmtBorrow are actually strings, and you
need to convert them to numbers. Val() does this, but beware it does no
error checking to see if the strings actually are valid numbers. If they are
not, the number used is zero.
 
D

Dave Lett

Hi Maurene,

You can try the following:

Dim oRng As Range
Set oRng = ActiveDocument.Bookmarks("ObDebtAmtBorrow").Range
ObDebt = InputBox("Enter ObDebt.", "ObDebt")
AmtBorrow = InputBox("Enter AmtBorrow.", "AmtBorrow")
oRng.Text = CInt(ObDebt) + CInt(AmtBorrow)
ActiveDocument.Bookmarks.Add _
Name:="ObDebtAmtBorrow", _
Range:=oRng

HTH,
Dave
 

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