Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have a userform with several textboxes that I want only numeric dat to be eneterd. Here is a sample of the code I have used for this: Private Sub OnlyNumbers() With Me.ActiveControl If Not IsNumeric(.Value) And .Value < vbNullString Then MsgBox "Sorry, only numbers allowed", 64, "Error Message" .Value = vbNullString End If End With End Sub Private Sub txtPrice_Change() OnlyNumbers txtPrice.Text = Format(txtPrice.Text, "#,##") End Sub Question 1 When setting up the tab order, I have set up #1 a textbox that can tak any alphanumeric characters, hence I have no 'formatting' code for thi box. The problem is I get the 'onlynumbers error message' come up when th form is opened. If I move the alphanumeric box down to number 2 in th tab order, the problem goes away! Question 2 I i want a textbox to contain the format "$ #,##" what do I need to d to the OnlyNumbers Private Sub to cater for the $ symbol and onl numeric data? Any help much appreciated and a happy new year to everyone Cheers Peter (new to VBA -- peter.thompso ----------------------------------------------------------------------- peter.thompson's Profile: http://www.excelforum.com/member.php...fo&userid=2968 View this thread: http://www.excelforum.com/showthread.php?threadid=49722 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
How to make a button VBA code reference other VBA code subroutines??? | Excel Programming | |||
Create a newworksheet with VBA code and put VBA code in the new worksheet module | Excel Programming | |||
stubborn Excel crash when editing code with code, one solution | Excel Programming |