Userform submitting values as text instead of numerical

majamke

New Member
Joined
Jul 27, 2012
Messages
10
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:

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!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top