Forcing numeric characters only at entry time in a text box on a user form
To answer your question:
-Since the Worksheet is already fromatted, does it matter if these are Dim'd as String or Long?
It can, depending if the numeric requires leading zeroes, if you need to export it to other systems, etc.
To answer your question:
-Lastly, would this be a seperate sub since the buttons are the only objects I have coded (Submit, Clear, Save&Exit)?
Yes...
Use the Change event of the text box in combination with the IsNumeric function to execute a validation of each keystroke entered into a textbox and alert the user with the MsgBox function if the character entered isn't a number. It executes after EVERY keystroke - adding as well as deleting characters. The sample code below will remove the non-numeric character entered if the user selects the 'Retry' option or clear the text box completely if the user selects the 'Cancel' option in the alert dialog.
Copy the code below to the code page of your user form (change reference to the textbox name to your own):
Hope this helps,
theDude
Bookmarks