• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Userform calculation the same as this spreadsheet

S P P

Member
Userform calculation the same as this spreadsheet
 

Attachments

  • SPP Userform calculation the same as this spreadsheet.xlsm
    25.6 KB · Views: 1
I got it like this

I can't understand, I type 255 in textbox1 and 13 in textbox2, the calculation is different to the spreadsheet.
If I type 256 it is the same as the calculation in the spreadsheet.

Other values are also the same as the spreadsheet.

How to fix this VBA so that it works like the spreadsheet

The Textbox3 first installment must have the same or greater value.
 

Attachments

  • SPP Userform calculation the same as this spreadsheet 1.xlsm
    24.9 KB · Views: 4
Round and RoundDown are not the same thing. You can change the code in the form to:

Code:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
       TextBox1.Value = Format(TextBox1.Value, "#,##0.00")
End Sub

Private Sub textbox1_change()
   UpdateValues
End Sub

Private Sub textbox2_change()
   UpdateValues
End Sub

Private Sub UpdateValues()
   If TextBox1.Value = "" Or TextBox2.Value = "" Then Exit Sub
   TextBox3 = Format(Application.RoundDown(TextBox1 / TextBox2.Value, 2) + TextBox1 - (Application.RoundDown(TextBox1 / TextBox2.Value, 2)) * TextBox2, "#,##0.00")
   TextBox4 = Format(Application.RoundDown(TextBox1 / TextBox2.Value, 2), "#,##0.00")

End Sub
 
Back
Top