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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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