![]() |
Textbox's return a number?
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 |
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 |
Textbox's return a number?
Use the textbox's change event along with isnumeric function to determine if
what is being entered is valid... -- HTH... Jim Thomlinson "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 |
All times are GMT +1. The time now is 07:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com