ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   formatting textboxes (https://www.excelbanter.com/excel-programming/437921-formatting-textboxes.html)

Roger on Excel

formatting textboxes
 
I populate textboxes on a userform with the following code

Private Sub cmdEditChemical_Click()
Dim Chemical As Variant

Chemical =
Sheets("Chemicals").Cells.Find(What:=lstChemicalDa tabase.Text,
LookIn:=xlFormulas, _
LookAt:=1, SearchDirection:=xlNext, MatchCase:=False).Offset(0,
0).Address

With Sheets("Chemicals").Range(Chemical)

TextBoxName.Text = .Offset(0, 0)
TextBoxCAS.Text = .Offset(0, 1)
TextBoxMW.Text = .Offset(0, 2)
TextBoxDensity.Text = .Offset(0, 3)
TextBoxConc.Value = .Offset(0, 4)
TextBoxMaterial.Text = .Offset(0, 5)
TextBoxSupplier.Value = .Offset(0, 6)
TextBoxPack.Value = .Offset(0, 7)
TextBoxUnit.Value = .Offset(0, 8)
TextBoxWasteClass.Value = .Offset(0, 9)
TextBoxCost.Value = .Offset(0, 10)

End With
End Sub

I need the textboxes to show particular formatting for example :

TextBoxCost needs to be $0.00 format
or
TextBoxConc needs to be XX.X% format

Can anyone help with the syntax of the code to help me with the formats?

Gary Keramidas

formatting textboxes
 
maybe this will point you in the right direction

Me.TextBox1.Value = Format(Worksheets("Sheet1").Range("A1").Value, "$0.00")


--


Gary Keramidas
Excel 2003


"Roger on Excel" wrote in message
...
I populate textboxes on a userform with the following code

Private Sub cmdEditChemical_Click()
Dim Chemical As Variant

Chemical =
Sheets("Chemicals").Cells.Find(What:=lstChemicalDa tabase.Text,
LookIn:=xlFormulas, _
LookAt:=1, SearchDirection:=xlNext, MatchCase:=False).Offset(0,
0).Address

With Sheets("Chemicals").Range(Chemical)

TextBoxName.Text = .Offset(0, 0)
TextBoxCAS.Text = .Offset(0, 1)
TextBoxMW.Text = .Offset(0, 2)
TextBoxDensity.Text = .Offset(0, 3)
TextBoxConc.Value = .Offset(0, 4)
TextBoxMaterial.Text = .Offset(0, 5)
TextBoxSupplier.Value = .Offset(0, 6)
TextBoxPack.Value = .Offset(0, 7)
TextBoxUnit.Value = .Offset(0, 8)
TextBoxWasteClass.Value = .Offset(0, 9)
TextBoxCost.Value = .Offset(0, 10)

End With
End Sub

I need the textboxes to show particular formatting for example :

TextBoxCost needs to be $0.00 format
or
TextBoxConc needs to be XX.X% format

Can anyone help with the syntax of the code to help me with the formats?




All times are GMT +1. The time now is 02:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com