Convert Userform textbox to percentage

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,368
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a userform with two textboxes that receive a number from a spreadsheet when double clicked. The numbers on the spreadsheet are percentages so I've formatted the textboxes to show the percentage. The code below works fine. I would now like to add those two textboxes together in another textbox on the userform and convert to a percentage. I tried the last code but get 5000% instead of what I would expect, 50%.

textbox16 = 25%
textbox17 = 25%

Without the Format of Textbxo19 I get 50, but again, when using the Format I get 5000%

Code:
[FONT=Verdana][FONT=Verdana]Private Sub UserForm_Activate()
    Dim cel     As Range: Set cel = ActiveCell
    Dim i       As Long
    
[/FONT][FONT=Verdana]    For i = 16 To 17[/FONT]
[FONT=Verdana]        Me.Controls("TextBox" & i).Value = Format(Sheet3.Range(cel.Address).Offset(, i + 4).Value, "0%")
    Next i[/FONT]
[/FONT][FONT=Verdana][FONT=Verdana]End Sub[/FONT][/FONT]



Code:
[FONT=Verdana]Sub AddMyVal()
    TextBox19.Value = Format(Val(TextBox16.Text) + Val(TextBox17.Text), "0%")
End Sub
[/FONT]
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Untested but maybe worth a try:

Rich (BB code):
Sub AddMyVal()
    TextBox19.Value = Format((Val(TextBox16.Text) + Val(TextBox17.Text))/100, "0%")
End Sub

 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top