Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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




.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional formatting and userform jknapp1005 Excel Discussion (Misc queries) 0 May 6th 09 04:53 PM
Userform Add hazel Excel Discussion (Misc queries) 8 November 3rd 06 07:01 PM
UserForm grahammal Excel Discussion (Misc queries) 15 April 10th 06 06:01 PM
UserForm CR Excel Discussion (Misc queries) 1 August 10th 05 10:26 PM
userform Antonov Excel Programming 1 September 2nd 03 04:25 AM


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"