+ Reply to Thread
Results 1 to 6 of 6

Get 5 Decimal places without rounding off

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    367

    Get 5 Decimal places without rounding off

    What is the format to get the 5 decimal places but without rounding off?

    Here's the sample:

    textbox1 / textbox2 = textbox3

    Textbox1 = 3768.62
    Textbox2 = 134
    Textbox3 should be only 28.12402

    I have this below formula but this still it's rounding.

    
    Private Sub TextBox1_Change()
    
    If IsNumeric(TextBox1) And IsNumeric(TextBox2) Then
           TextBox3.Value = Format(TextBox1 / TextBox2, "####.00000")
          
          
       Else
       
       TextBox3.Value = ""
    
        End If
    
    
    End Sub
    
    Private Sub TextBox2_Change()
    
    
    If IsNumeric(TextBox1) And IsNumeric(TextBox2) Then
           TextBox3.Value = Format(TextBox1 / TextBox2, "####.00000")
        
           
          
       Else
       TextBox3.Value = ""
       
        End If
    
    
    End Sub

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,037

    Re: Get 5 Decimal places without rounding off

    try

    TextBox3.Value = Format(INT(10000*TextBox1 / TextBox2)/10000, "####.00000")
    Never use Merged Cells in Excel

  3. #3
    Forum Contributor
    Join Date
    02-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    367

    Re: Get 5 Decimal places without rounding off

    Hi zbor, it getting me a result of 28.12400 when trying to use your code

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,037

    Re: Get 5 Decimal places without rounding off

    try add one more 0
    TextBox3.Value = Format(INT(100000*TextBox1 / TextBox2)/100000, "####.00000")

  5. #5
    Forum Contributor
    Join Date
    02-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    367

    Re: Get 5 Decimal places without rounding off

    Now it works! thanks! zbor!

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,037

    Re: Get 5 Decimal places without rounding off

    Also, you could get error if Textbox2 is 0

    try something like:

    Private Sub TextBox1_Change()
    
    On error resume next
       TextBox3.Value = ""
       TextBox3.Value = Format(INT(100000*TextBox1 / TextBox2)/100000, "####.00000")
    
    End Sub
    
    Private Sub TextBox2_Change()
    
    On error resume next
       TextBox3.Value = ""
       TextBox3.Value = Format(INT(100000*TextBox1 / TextBox2)/100000, "####.00000")

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1