Rounding Up Numbers using VB

Mark.B

Board Regular
Joined
Jun 14, 2004
Messages
136
Hi there.

Within a VB procedure i have a very simple calculation i.e. Number 1 divided by Number 2 = Answer.
The results returned always have multiple decimal places i.e. 98.827876.

I would like to pass / insert this value into a Textbox which has been embedded into a Worksheet, but I need it to appear as a % with either 1 or no decimal places.

I've added the % symbol in the simplest that I know i.e. TextboxText = Answer & "%" but the end result shows as 98.827876% (I need to lose all of the decimal places)

Is it possible to Round Up the "Answer" to the calculation being performed inside the procedure within VB ?

or

Can I limit the value which is being passed to the embedded textbox so that the end result is simply 98.8% or 99% ?

Hope this makes sense.

Any help would be greatly appreciated.
 

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.
How about
VBA Code:
Me.TextBox3 = Application.RoundUp(answer, 1) & "%"
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,377
Members
448,955
Latest member
BatCoder

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