T
thesteelmaker
Using the code below i can enter a numeric value to a textbox, whic
ends up as 2 decimal places (in the textbox).
But when entered to cell "A1" the format is still "General".
i.e. if i enter 6.1 into my textbox it ends up as 6.1 on the s/shee
and not as 6.10 as i want it.
Any help.
Thanks
Private Sub cmbAdd_Click()
' Select sheet and cell
ActiveWorkbook.Sheets("Sheet1").Activate
Range("A1").Select
' Format and enter data
TextBox1.Text = Format$(UserForm1.TextBox1.Text, "####0.00")
' Varify numeric
If IsNumeric(TextBox1) = False Then
MsgBox "You inserted a non-numeric, try again."
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
Exit Sub
Else
ActiveCell.Value = TextBox1.Text
End If
' Clear box after adding data
TextBox1.Text = ""
End Sub
Private Sub UserForm_Initialize()
TextBox1.Text = ""
TextBox1.SetFocus
End Su
ends up as 2 decimal places (in the textbox).
But when entered to cell "A1" the format is still "General".
i.e. if i enter 6.1 into my textbox it ends up as 6.1 on the s/shee
and not as 6.10 as i want it.
Any help.
Thanks
Private Sub cmbAdd_Click()
' Select sheet and cell
ActiveWorkbook.Sheets("Sheet1").Activate
Range("A1").Select
' Format and enter data
TextBox1.Text = Format$(UserForm1.TextBox1.Text, "####0.00")
' Varify numeric
If IsNumeric(TextBox1) = False Then
MsgBox "You inserted a non-numeric, try again."
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
Exit Sub
Else
ActiveCell.Value = TextBox1.Text
End If
' Clear box after adding data
TextBox1.Text = ""
End Sub
Private Sub UserForm_Initialize()
TextBox1.Text = ""
TextBox1.SetFocus
End Su