format number in textbox on userform

MKLAQ

Board Regular
Joined
Jan 30, 2021
Messages
108
Office Version
  1. 2016
Platform
  1. Windows
hello
I have 4 textboxes linked with 4 cells when I run the userform should show the number like this 1,200,300.00 in four textboxes
this what i got but not work


VBA Code:
Private Sub UserForm_Activate()
TextBox1.value = Format(TextBox1.value, "#,##0.00")
TextBox2.value = Format(TextBox2.value, "#,##0.00")
TextBox3.value = Format(TextBox3.value, "#,##0.00")
TextBox4.value= Format(TextBox4.value, "#,##0.00")
End Sub
any suggestion,please ?
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
564
Office Version
  1. 2010
Platform
  1. Windows
Hi,​

If the cell is well formatted so the better is to use the Text property of the cell rather than formatting the Text Box …​
 

6StringJazzer

Well-known Member
Joined
Jan 27, 2010
Messages
843
Office Version
  1. 365
Platform
  1. Windows
I missed that the textboxes are linked to cells. If you change the textboxes as shown, it will update the linked cells to text, and then may re-convert to numbers and you are back where you started. If you care about the formatting in the textboxes you should not link them to cells to populate them. That technique should be used only to enter data in the textboxes that will be used to populate the cells.

You need to explain your whole scenario so we can suggest an alternative approach.
 

MKLAQ

Board Regular
Joined
Jan 30, 2021
Messages
108
Office Version
  1. 2016
Platform
  1. Windows
@6StringJazzer I've found many solution by change or exit event but this is not what I want , theses work when enter the values as you said but I want to do that when I userform like search theses texboxes linked with listbox when run the userform should show all data in listbox and textboxes by Activate or Initialize events in userform , is it possible?
 

Watch MrExcel Video

Forum statistics

Threads
1,130,041
Messages
5,639,710
Members
417,106
Latest member
rbahena

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
Top