Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
Digits in textbox's
Hi all just wondering how I can get someone only to type number in a certain
textbox? Thanks in advance Greg |
#2
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
Digits in textbox's
Is this a TextBox on a UserForm?
Somewhat crude, but try the following: Private Sub TextBox1_Change() If Not IsNumeric(TextBox1.Text) Then _ SendKeys "{BACKSPACE}" End Sub -- Vasant "Greg B" wrote in message ... Hi all just wondering how I can get someone only to type number in a certain textbox? Thanks in advance Greg |
#3
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
Digits in textbox's
Thank you for that
Greg "Vasant Nanavati" <vasantn AT aol DOT com wrote in message ... Is this a TextBox on a UserForm? Somewhat crude, but try the following: Private Sub TextBox1_Change() If Not IsNumeric(TextBox1.Text) Then _ SendKeys "{BACKSPACE}" End Sub -- Vasant "Greg B" wrote in message ... Hi all just wondering how I can get someone only to type number in a certain textbox? Thanks in advance Greg |
#4
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
Digits in textbox's
Better than SendKeys, use the KeyPress event.
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii < 48 Or KeyAscii 57 Then KeyAscii = 0 End If End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Vasant Nanavati" <vasantn AT aol DOT com wrote in message ... Is this a TextBox on a UserForm? Somewhat crude, but try the following: Private Sub TextBox1_Change() If Not IsNumeric(TextBox1.Text) Then _ SendKeys "{BACKSPACE}" End Sub -- Vasant "Greg B" wrote in message ... Hi all just wondering how I can get someone only to type number in a certain textbox? Thanks in advance Greg |
#5
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
Digits in textbox's
Hi Chip:
I knew there was a better solution but just couldn't get my brain to come up with it <g. Regards, Vasant "Chip Pearson" wrote in message ... Better than SendKeys, use the KeyPress event. Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii < 48 Or KeyAscii 57 Then KeyAscii = 0 End If End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Vasant Nanavati" <vasantn AT aol DOT com wrote in message ... Is this a TextBox on a UserForm? Somewhat crude, but try the following: Private Sub TextBox1_Change() If Not IsNumeric(TextBox1.Text) Then _ SendKeys "{BACKSPACE}" End Sub -- Vasant "Greg B" wrote in message ... Hi all just wondering how I can get someone only to type number in a certain textbox? Thanks in advance Greg |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA write macro change column with 3 number digits to 4 digits the | Excel Discussion (Misc queries) | |||
How to customize number to 10 digits including 2 digits after deci | Excel Worksheet Functions | |||
Digits in textbox's | Excel Discussion (Misc queries) | |||
Textbox's truncated once printed (Excel 2000) | Excel Discussion (Misc queries) | |||
Textbox's and Dates the usual conflict | Excel Programming |