Formatting 2 TextBoxes as Currency

tigerdel

Board Regular
Joined
Oct 13, 2015
Messages
145
Office Version
  1. 365
Platform
  1. Windows
Hi Guys

I have a userform with 3 textboxes on:

TextBox1 = the user enters gross value
TextBox2 = user enters VAT Rate as a number [not a percentage]
TextBox3 = Calculates the Nett Value

If I use this code:
Code:
Private Sub textbox1_Change()
    TextBox1.value = Format(TextBox1.value, "Currency")
    TextBox3.value = Format(TextBox3.value, "Currency")
    TextBox3.value = Val(TextBox1.value) / Val(TextBox2.value + 100) * (100)
End Sub

The calculation works but the formatting fails

Any ideas??

Many thanks

Derek
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
OK so something definitely amiss

I was going to attach the workbook but I am apparently not allowed to attach attachments

code now looks like this:

Code:
Private Sub TextBox1_Change()
    TextBox1.value = Format(TextBox1.value, "£#,##0.00")
    TextBox3.value = Format(TextBox3.value, "£#,##0.00")
    TextBox3.value = Val(TextBox1.value) / Val(TextBox2.value + 100) * (100)
End Sub
I still can't get it to work properly

Cheers all

Derek
 
Upvote 0
Hello again,

Could you kindly test exactly the following code ...

Code:
[COLOR=#333333]Private Sub TextBox1_Change()[/COLOR]
[COLOR=#333333]TextBox1.value = Format(TextBox1.value, "[/COLOR][COLOR=#ff0000][B]$[/B][/COLOR][COLOR=#333333]#,##0.00")[/COLOR]
[COLOR=#333333]TextBox3.value = Format(TextBox3.value, "[/COLOR][COLOR=#ff0000][B]$[/B][/COLOR][COLOR=#333333]#,##0.00")[/COLOR]
[COLOR=#333333]TextBox3.value = Val(TextBox1.value) / Val(TextBox2.value + 100) * (100)[/COLOR]
[COLOR=#333333]End Sub[/COLOR]

And afterwards ... feel free to comment ...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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