VBA Userform, multiplying number with percentage

gulli09

New Member
Joined
Dec 28, 2011
Messages
37
I'm designing a userform. I'm multyplying two textboxes together, one of the textboxes is a number and the other one is a percentage.

First of all I had problems changing the format to a percentage. If there is an easier way to change the format that works that would be great as well. The code currently works that way that as soon as both the percentage and the number is in place they multiply together in another textbox. When I change the format to a percentage the calculations aren't able to recognize the percentage for a percentage and return nothing(eg. when the % is added, it's calculated as number*nothing, and thus returning nothing because it doesn't read the percentage as a number as soon as the % is added)

I basically need to trick the calculator into beliving there is no % sign, whilst at the same time showing the % sign to the user.

In a nutshell it's one textbox were the users enters f.x. 15, and the outcome is 15% he then enters a number, f.x. 100 and then in a 3rd textbox it calculates 15%*100 returning 15. What would be the best way to achieve this? I can provide the code if nescessary.
 
Managed to fix it by writing in the end of the code;

txtMulti1.Text = Format(Val(txtMulti1.Text),”#,##0”)

I managed to fix it, and the same with the txtnum2 textbox
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,216,077
Messages
6,128,679
Members
449,463
Latest member
Jojomen56

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