ActiveX Textboxes

flavioso

New Member
Joined
Oct 29, 2008
Messages
20
I have an excel sheet that has a header row where users put values in an ActiveX textbox. My problem is percentages. I have tried to create a textbox where if the user puts 5 into it, the textbox would display 5%, instead it comes back with 500%. I cannot figure out what code to put in to eliminate this I have tried the change and exit event and it still puts 500% in the text box. Does anyone have any solution? This is an ActiveX field on a excel sheet, not on a userform.

I appreciate any help and suggestions.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Can you show us the code that you've used?

Here's what I would use:

Code:
Private Sub TextBox1_LostFocus()
    If Len(TextBox1.Text) = 0 Then Exit Sub
    
    If InStr(1, TextBox1.Text, "%") = 0 Then
        TextBox1.Text = Format$(TextBox1.Text / 100, "0%")
    End If
End Sub

You can change the 0% to include more decimals.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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