Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping through TextBox's PaulW Excel Programming 1 October 1st 07 04:49 PM
Looping through TextBox's Bob Phillips Excel Programming 0 October 1st 07 04:36 PM
Tabbing between textbox's dr chuck Excel Programming 3 September 3rd 06 07:04 PM
Digits in textbox's Greg B Excel Discussion (Misc queries) 4 September 4th 05 06:23 PM
Digits in textbox's Greg B[_5_] Excel Programming 4 September 4th 05 06:23 PM


All times are GMT +1. The time now is 01:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"