Percents in VBA

billyshears

Board Regular
Joined
Aug 29, 2013
Messages
61
Cell A1=a variable value

I have a userform that I can type numbers into. In the userform I type 10

I then want that number I entered in the userform to multiply Cell A1 by the userform number %

So if I type 10 in the userform, I want cell A1 to increase by 10%

If I type 5 into the userform, Cell A1 increases by 5%

I cant seem to get this working correctly. Do I format the text box in the userform as a %? or is this done in the VBA coding?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi Billy
your form is able to take anything as input, to make it robust you'll want to validate anything entered to be a number so the code doesn't break when someone types in their name. On your form label the field with a % after it so the user doesn't think they need to include the % symbol.
then in the VBA you want something like cells("A1").value = cells("A1").value * (1+<value from form)/100)
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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