Thread: cell formatting
View Single Post
  #12   Report Post  
Jean-Guy Marcil
 
Posts: n/a
Default

Darryl was telling us:
Darryl nous racontait que :

Thanks Anne.

I understand that 8.7 is not 8.7%. But as the users say, I need it
this way.
I don't know how to make it such that when the user leaves the field
in the table, that the resulting value (870%) is divided by 100 so it
shows 8.7% (the goal).


Here is a little macro that does that:

'_______________________________________
Sub Divide100()

Dim myValue As Single

With ActiveDocument.Bookmarks("Value1").Range
myValue = CSng(Left(.Text, Len(.Text) - 1))
myValue = myValue / 10000
.FormFields(1).Result = CStr(myValue)

End With

End Sub

'_______________________________________

Note that I have to divide by 10 000 because when I do the calculation, the
number entered by the user a=has already been multiplied by a 100 because of
the number format...

The formfield name is Value1.
Either change the name in the macro, or change it in the form itself.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org