Text format as percentage
Try replacing the first line after the If statement with this one instead
(leave the rest of your code as is)...
TextBox21 = Replace(TextBox21, "%", "") / 100
--
Rick (MVP - Excel)
"Shane" wrote in message
...
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!
|