ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   force text/numbers in text box (https://www.excelbanter.com/excel-programming/404598-force-text-numbers-text-box.html)

pswanie

force text/numbers in text box
 
is there a way to force my user to enter only numbers in a textbox?
and in other only letters?
theres quite a few textboxe's

some thing like this perhaps?

with me.
textbox1
textbox2
textbox3
..numbers.only

thanx all

Mike H

force text/numbers in text box
 
Hi,

Right click each textbox, view code and paste this in to ensure numbers
only. Remove 'Not' to ensure letters only, Don't forget to change the name of
the text box as appropriate.

Private Sub TextBox1_Change()
If Not IsNumeric(TextBox1.Value) And TextBox1.Value < vbNullString Then
MsgBox "Sorry, only numbers/letters allowed"
TextBox1.Value = vbNullString
End If
End Sub


Mike
"pswanie" wrote:

is there a way to force my user to enter only numbers in a textbox?
and in other only letters?
theres quite a few textboxe's

some thing like this perhaps?

with me.
textbox1
textbox2
textbox3
.numbers.only

thanx all


pswanie

force text/numbers in text box
 
thanx rick...

one more Q. how will i go to the last cell in column b and make that the
caption for label1?


As for your second item, this will do it...

Label1.Caption = Cells(25, "B").Value

Rick


"pswanie" wrote in message
...
i got a few labels on a userform. most of them in a frame.

1) few of them need to show data in sheet1 colum a cell 1 untill empty row

2) other just need to show sheet1 column b cell 25





All times are GMT +1. The time now is 05:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com