Userform Formatting
Thank you. That worked beautiful!
-----Original Message-----
"Todd Huttenstine"
wrote in message
...
That works but if a value in one of textboxes shows 10%
for instance, I get a debug error. All the values in
the
textboxes must be raw numbers. How do I get around
this?
Also what if I wanted to just type a number in the
textboxes and have the % automatically appear on the
end?
For that I suggest that you use a textbox event code
Private Sub CommandButton1_Click()
With Worksheets("Pay Calculator")
.Range("AA1").Value = TextBox1.Value
.Range("AA2").Value = TextBox2.Value
.Range("AA3").Value = TextBox3.Value
.Range("AA4").Value = TextBox4.Value
Unload UserForm1
End With
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
With TextBox1
If Right(.Text, 1) = "%" Then
.Text = Left(.Text, Len(.Text) - 1)
End If
.Text = Format(.Text / 100, "0%")
End With
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
With TextBox2
If Right(.Text, 1) = "%" Then
.Text = Left(.Text, Len(.Text) - 1)
End If
.Text = Format(.Text / 100, "0%")
End With
End Sub
Private Sub TextBox3_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
With TextBox3
If Right(.Text, 1) = "%" Then
.Text = Left(.Text, Len(.Text) - 1)
End If
.Text = Format(.Text / 100, "0%")
End With
End Sub
Private Sub TextBox4_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
With TextBox4
If Right(.Text, 1) = "%" Then
.Text = Left(.Text, Len(.Text) - 1)
End If
.Text = Format(.Text / 100, "0%")
End With
End Sub
.
|