R
Roger on Excel
I populate textboxes on a userform with the following code
Private Sub cmdEditChemical_Click()
Dim Chemical As Variant
Chemical =
Sheets("Chemicals").Cells.Find(What:=lstChemicalDatabase.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?
Private Sub cmdEditChemical_Click()
Dim Chemical As Variant
Chemical =
Sheets("Chemicals").Cells.Find(What:=lstChemicalDatabase.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?