View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
shane shane is offline
external usenet poster
 
Posts: 72
Default Text format as percentage

I have a userform that I use multiple times. When this form loads the first
time, I use the following code to format the text to a percentage:

Private Sub TextBox21_afterupdate()
If TextBox21.Value < "" Then
TextBox21 = TextBox21 / 100
With UserForm1.TextBox21
.Text = Format(.Text, "0.00%")
End With
End If

however, if I ever focus back on that textbox, and then focus off, it
crashes the code. how would I add code that basically says "if the number is
already in percentage format, ignore the rest of this code"? (or is there a
better way to write the above code to fix this error all together?)

Thanks!