how to roundup and round down textbox value

manissinha

New Member
Joined
Jul 7, 2017
Messages
9
Hi All,

I have created userform and want to roundup and round down the entered values

If i enter positive value with decimal value it should round down
example if i enter 5.01 it should give 5.00 , or for 5.99 should give 5.00

If i enter negative value with decimal value it should round up
example if i enter 5.01 it should give 6.00 , or for 5.99 should give 6.00

regards
manish
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Code:
Private Sub TextBox1_AfterUpdate()
  With TextBox1
    If Not IsNumeric(.Value) Then Exit Sub
   .Value = Format(Evaluate("int(" & .Value & ")"), "0.00")
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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