FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,368
- Office Version
- 365
- 2016
- Platform
- 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%
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: