Textbox Formatting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a userform with a textbox where the user needs to enter a number. When
the form is submitted that data goes to a specific cell in a worksheet. But
the number goes into the cell as text. How do I get it to go into the cell as
a number. I have tried to format the cell in the worksheet but it changes
back to text everytime. Thanks in advance for any help.
 
try one of these in your code Im not sure were to tell you to put it without
seeing your code. but this should work for you
Columns("A:A").Select
Selection.NumberFormat = "0.00"

ActiveCell.Select
Selection.NumberFormat = "0.00"
 
Thanks Mike for the help. Unfortunatley I am just learning this stuff. I
pasted my code below for you to look at if you want to. The problem text
boxes are txtMan_Hours.Value = ""
txtMach_Hours.Value = ""

On the form I enter the hours (i.e. 8 or 10) and on the work sheet
"Manufaturing_Time_Data" columns H and I are populated by 8 or 10 but they
are text instead of numbers.

Thanks again


Private Sub cmdClear_Click()

Call UserForm_Initialize

End Sub
_______________________________________________________
Private Sub cmdSubmit_Click()
ActiveWorkbook.Sheets("Manufacturing_Time_Data").Activate
Range("A1").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtDate.Value
ActiveCell.Offset(0, 1) = cboName
ActiveCell.Offset(0, 2) = cboDepartment
ActiveCell.Offset(0, 3) = cboEmplyType
ActiveCell.Offset(0, 4) = cboCatagory
ActiveCell.Offset(0, 5) = txtProject_PID
ActiveCell.Offset(0, 6) = txtActivity_Sequence
ActiveCell.Offset(0, 7) = txtMan_Hours
ActiveCell.Offset(0, 8) = txtMach_Hours
If chkIs_Sequence_Complete = True Then
ActiveCell.Offset(0, 9) = "Yes"
Else
ActiveCell.Offset(0, 9) = "No"
End If
ActiveWorkbook.Save
ActiveWorkbook.Sheets("Console").Activate
Unload Me
End Sub
__________________________________________
Private Sub UserForm_Initialize()
With cboName
.AddItem "Alvarez, Cesar"
.AddItem "Boyd, Wallace"
.AddItem "Cardenas, Eustorgio"
.AddItem "Carranza, Ricardo"
End With
cboName.Value = ""
With cboDepartment
.AddItem "1423"
.AddItem "1424"
.AddItem "1425"
End With
cboDepartment.Value = ""
With cboEmplyType
.AddItem "FULL"
.AddItem "TEMP"
End With
cboEmplyType.Value = ""
txtProject_PID.Value = ""
txtActivity_Sequence.Value = ""
txtMan_Hours.Value = ""
txtMach_Hours.Value = ""
With cboCatagory
.AddItem "REGPY"
.AddItem "OVT"
.AddItem "NSREG"
.AddItem "OFFSH"
.AddItem "NSOT"
.AddItem "SICK"
.AddItem "VAC"
.AddItem "HLDY"
End With
cboCatagory.Value = ""
chkIs_Sequence_Complete = False
txtDate.Value = ""
txtDate.SetFocus

End Sub
 
try this
Private Sub cmdSubmit_Click()
ActiveWorkbook.Sheets("Manufacturing_Time_Data").Activate
Columns("H:I").Select
Selection.NumberFormat = "0.00"
Range("A1").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtDate.Value
ActiveCell.Offset(0, 1) = cboName
ActiveCell.Offset(0, 2) = cboDepartment
ActiveCell.Offset(0, 3) = cboEmplyType
ActiveCell.Offset(0, 4) = cboCatagory
ActiveCell.Offset(0, 5) = txtProject_PID
ActiveCell.Offset(0, 6) = txtActivity_Sequence
ActiveCell.Offset(0, 7) = txtMan_Hours
ActiveCell.Offset(0, 8) = txtMach_Hours
If chkIs_Sequence_Complete = True Then
ActiveCell.Offset(0, 9) = "Yes"
Else
ActiveCell.Offset(0, 9) = "No"
End If
ActiveWorkbook.Save
ActiveWorkbook.Sheets("Console").Activate
Unload Me
End Sub
__________________________________________
Private Sub UserForm_Initialize()
With cboName
.AddItem "Alvarez, Cesar"
.AddItem "Boyd, Wallace"
.AddItem "Cardenas, Eustorgio"
.AddItem "Carranza, Ricardo"
End With
cboName.Value = ""
With cboDepartment
.AddItem "1423"
.AddItem "1424"
.AddItem "1425"
End With
cboDepartment.Value = ""
With cboEmplyType
.AddItem "FULL"
.AddItem "TEMP"
End With
cboEmplyType.Value = ""
txtProject_PID.Value = ""
txtActivity_Sequence.Value = ""
txtMan_Hours.Value = ""
txtMach_Hours.Value = ""
With cboCatagory
.AddItem "REGPY"
.AddItem "OVT"
.AddItem "NSREG"
.AddItem "OFFSH"
.AddItem "NSOT"
.AddItem "SICK"
.AddItem "VAC"
.AddItem "HLDY"
End With
cboCatagory.Value = ""
chkIs_Sequence_Complete = False
txtDate.Value = ""
txtDate.SetFocus

End Sub
 
Back
Top