Decimal display in textboxes.

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
Good Day,
I have a userform with a lot of text boxes.
And its pop up with same code given below.
I did not put other text boxes i've just add one sample...

VBA Code:
Private Sub UserForm_Initialize()

Me.TextBox1.Text = Format(Sheets("list").Range("G1").Value, "###,##")

End Sub


My question is,
Is it possible to put only a code that all textboxes will display with the format of "###,##" without stating the textboxes one by one.
Simply those textboxes with the numbers will format automaticly.
Also some textboxes has text values on my userform.
Thanks in advance.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I don't know that with a single instruction you can change all the textboxes.
But with a loop you can go through all the textboxes and put a value in them.

At least you would have put 3 textboxes to identify a pattern.

So:
Are all texboxes filled with cell G1?
Or textbox1 with cell G1, textbox2 with cell G2, textbox3 with cell G and so on?

With the following code you can format up to 20 textboxes, change the 20 to the number of textboxes you have in your userform.
Each will be filled with cells G1 to G20.

VBA Code:
Private Sub UserForm_Initialize()
  Dim i As Long

  For i = 1 To 6
    Controls("TextBox" & i).Text = Format(Sheets("list").Range("G" & i).Value, "###,##")
  Next
End Sub

If the textboxes are filled with different cells then you must explain which ones you need filled with numbers and which cells, to identify a pattern and fill them all with the cycle.

🧙‍♂️
 
Upvote 0
I don't know that with a single instruction you can change all the textboxes.
But with a loop you can go through all the textboxes and put a value in them.

At least you would have put 3 textboxes to identify a pattern.

So:
Are all texboxes filled with cell G1?
Or textbox1 with cell G1, textbox2 with cell G2, textbox3 with cell G and so on?

With the following code you can format up to 20 textboxes, change the 20 to the number of textboxes you have in your userform.
Each will be filled with cells G1 to G20.

VBA Code:
Private Sub UserForm_Initialize()
  Dim i As Long

  For i = 1 To 6
    Controls("TextBox" & i).Text = Format(Sheets("list").Range("G" & i).Value, "###,##")
  Next
End Sub

If the textboxes are filled with different cells then you must explain which ones you need filled with numbers and which cells, to identify a pattern and fill them all with the cycle.

🧙‍♂️
Or textbox1 with cell G1, textbox2 with cell G2, textbox3 with cell G and so on?
Yes correct. Instead of editingone by one on current codes I would like to show on text boxes with deciminal.
 
Upvote 0
Or textbox1 with cell G1, textbox2 with cell G2, textbox3 with cell G and so on?
Yes correct. Instead of editingone by one on current codes I would like to show on text boxes with deciminal.
I don't understand you.
Did you try the code I put in post #2?
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,118
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