Round up to "0.5" using code

glockster

Board Regular
Joined
Mar 24, 2002
Messages
181
The typcail code in Excel VBA doesn't work in Word. How can I take a number in a TextBox in a UserForm and round it UP to 0.5 (ie: "1.2" becomes "1.5").
The following example codes didn't work:

TextBox1.Value = Round(TextBox2.Value * 0.03, 0.5)
TextBox1.Value = Round((TextBox2.Value * 0.03) / 0.5, 0) * 0.5
TextBox1.Value = -Int(-(TextBox2.Value * 0.03) * 0.5 / 0.5)
TextBox1.Value = -Int(-(TextBox2.Value * 0.03) * 2 / 2)
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Eh, isn't 1.2*0.03 = 0.036.:eek:

Don't quite see how that would round up to 1.5, or am I missing something.:)
 
Upvote 0
I abbreviated my original formula just to make it easier to understand.


"cbd1" returns an error saying sub or function not defined.
 
Upvote 0
It's L not 1.:)

And it's db not bd.
 
Last edited:
Upvote 0
I'm not sure what I provided will do what you want as a value like 1 will get rounded to 1.5, so work still needs to be done if you want that 1 to stay as 1.
 
Upvote 0

Forum statistics

Threads
1,216,057
Messages
6,128,521
Members
449,456
Latest member
SammMcCandless

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