View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Richard Buttrey Richard Buttrey is offline
external usenet poster
 
Posts: 296
Default checking input on a textbox in userform to be a %

Maybe I'm missing something, but a percentage is just another number.
Your original question was primarily about the format or appearance of
that number.

Did you try my suggested code in the UserForm_terminate() event ?

i.e.

Private Sub UserForm_Terminate()
If Range("a1") 1 Then Range("a1") = Range("a1") / 100
End Sub


It's not immediately apparent why, if the other code that you mention
below works, why it doesn't also work for a percentage number.

Rgds


On Fri, 19 Aug 2005 11:47:51 GMT, "Jean-Pierre D via OfficeKB.com"
wrote:

Hi richard,
your input does not work for me....
on another userform i lat vba code check is an input is numeric with this
code:

Private Sub OnlyNumbers(ctl As Object)
With ctl
If Not IsNumeric(.Value) And .Value < vbNullString Then
MsgBox "Sorry, alleen getallen toegestaan"
.Value = vbNullString
.SetFocus
End If
End With
End Sub

and then with each field

Private Sub nw_franchise_change()
OnlyNumbers nw_franchise
End Sub

Now i would like to have something similar for input of percentages !
can you plese help me?
JP

Richard Buttrey wrote:
Hi,

[quoted text clipped - 10 lines]
thanks,
Jean-Pierre


You could try something like

If Range("a1") 1 Then Range("a1") = Range("a1") / 100

in the UserForm Terminate event, or some other suitable event.

Rgds

Rgds
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________