Hi,
I have a userform containing a number of textboxes where the input will be numbers only. I've managed to prevent users from entering non-numerical characters in the textboxes, however when the command button is clicked and the values are put in the worksheet, the values are stored as text, not numbers.
How can I get the userform to submit numbers instead of text?
My code is below:
Command button close:
You help is much appreciated!
I have a userform containing a number of textboxes where the input will be numbers only. I've managed to prevent users from entering non-numerical characters in the textboxes, however when the command button is clicked and the values are put in the worksheet, the values are stored as text, not numbers.
How can I get the userform to submit numbers instead of text?
My code is below:
Code:
Private Sub AUD_SPEC_Change()
Dim okstop As Boolean
Dim yesno_continue As Boolean
Dim mytext As String
okstop = False
Do
mytext = AUD_SPEC.Value
If Not IsNumeric(mytext) And mytext <> "" Then
AUD_SPEC.Value = ""
yesno_continue = MsgBox("Please type numbers only." & _
Chr(13) & "Continue?", vbYesNo)
Else
okstop = True
End If
Loop Until (yesno_continue = vbNo) Or (okstop = True)
End Sub
Command button close:
Code:
Private Sub Submit_Click()
' Insert data into Receipts tab
Worksheets("Receipts").Range("Start").End(xlDown).Select
With Selection
.Offset(1, 2) = AUD_SPEC
.Offset(1, 9) = CTAUDSPEC
.Offset(1, 13) = TREASURY
.Offset(1, 15) = ACTSPEC
.Offset(1, 16) = OTHER_CHARGES
End With
Unload Receipts_Form
End Sub
You help is much appreciated!