0

Is it possible to set a format to a UserForm textbox so that it automatically changes the numbers from 123456789.123456789 to 123,456,789.123456789.

Private Sub TextBox1_Change()
TextBox1.Value = Format(TextBox1.Value, "#,###.##")
End Sub

I used this, but it round the number to 123,456,789.12 .

Is 123,456,789.123456789 possible within the VBA ? Thanks.

3
  • try Format(TextBox1.Value, "#,##0.000000000") Commented Oct 23, 2014 at 13:20
  • but if you enter the number like this 123456789.12345 it will update to this 123,456,789.123450000 Commented Oct 23, 2014 at 14:43
  • I have seen how does this work in other applications (maybe not VBA) and I try to create something like that in my code )) Commented Oct 23, 2014 at 14:45

1 Answer 1

1

You can add as many # as you want to specify the number of figures after the dot. In your case you can use a format

Format(TextBox1.Value, "#,###.#########")

Should work.

Sign up to request clarification or add additional context in comments.

3 Comments

Yes it should cuts the 0s.
it doesn't cut the 0s ((
It has the proper behavior in excel on my side. I don't see why it would be different in VBA. Try formatting in general first "General" and then reformat again maybe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.