View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Textbox's return a number?

You have to test if the number is numeric and if it is not then have the text
box re-open with an error message

Use isnumeric

do
if not isnumeric(UserForm1.TextBox1.Value) then
enter error message
end if
while not isnumeric(UserForm1.TextBox1.Value)

ActiveCell.Offset(0, 0).Value = UserForm1.TextBox1.Value



"Adam" wrote:

Hi

I have a userform where users enter infomation into a textbox, upon
hitting an enter button my code puts the infomation into the
spreadsheet.

ActiveCell.Offset(0, 0).Value = UserForm1.TextBox1.Value

My problem is some of the infomation must be a number i.e. a quantity.

How can i change the code to accept only a number in certain
textboxes?

Thanks in advance