Percentage formats in User Form text boxes

scoha

Active Member
Joined
Jun 15, 2005
Messages
428
I have a user form which includes some text boxes (txtRUL.text for example) where I want to enter a number as a percentage. I divide the number entered by 100 to avoid Excel automatically multiplying by 100 and the result is displayed in the user form as the correct percentage.

Private Sub txtRUL_AfterUpdate()
EnableSave
txtRUL.Value = Format(txtRUL.Value / 100, "0.0%")

(I'm sorry I cant figure out how to format this code as code in this post)

This works well, trouble is when I save and it writes the results to the worksheet, the numbers in the user form revert back to plain unformatted non percentage numbers (ie 5% goes to 0.05)

Any ideas?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
jindon - that was what was needed! Works just as I need it - thanks very much for persisting with this matter.
 
Upvote 0
I know this is an old thread but I've recently run into this problem and HaHoBe's answer provided a clue that helped me resolve it. But the issue has several dimensions and the lack of final resolution to this thread suggests that it's not well articulated.

In this scoha's case, the problem may be that the array of worksheet cells being referenced may be formatted as "General" formatting (the default), which will automatically convert percentages to decimals when writing to them and reading form them.

In my case, I'm using the ControlSource property of a Textbox contained in an ActiveX Frame control. Here's the general case, and resolution for these kinds of situations:

If the Textbox has its LinkedCell (or ControlSource) property set to refer to a worksheet cell, or if VBA code explicitly copies data to and from a worksheet cell, then the problem may be that Excel’s cell formatting system is overriding the Textbox’s value format. The fix for this problem is to ensure that the targeted LinkedCell (or ControlSource) cell, or the explicitly written/read cell, is explicitly formatted to Text format (“@”) or Percentage format (“0.00%”, “#%”, etc.).
 
Upvote 0

Forum statistics

Threads
1,215,883
Messages
6,127,545
Members
449,385
Latest member
KMGLarson

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