![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Where the wild roses grow
Posts: 285
|
I am designing a form and in one of the text boxes I would like to have something like an input mask, like the ones used in Access. Basically I need all the users to put in a seven digit number. If they dont and put a six digit or eight digit etc, then I need a msgbox to appear saying "This field needs to contain seven digits"
Can anyone help? [ This Message was edited by: Audiojoe on 2002-03-07 08:45 ] |
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Mar 2002
Location: Hilo, Hawaii
Posts: 240
|
Quote:
Dim MyStr1 As String, MyLen Sub DetermineLength() MyStr1 = InputBox("Insert Seven Digits") MyLen = Len(MyStr1) If MyLen <> 7 Then MsgBox ("not 7 digits") Range("A1").Value = "" Else MsgBox ("Cool") Range("A1").Value = MyStr1 End If End Sub |
|
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
As an alternative, if you don't require a text box, you can use data validation to specify the text length in an individual cell. On the data menu select validation, for a validation criteria select text length, then set the minimum and maximum length for 7.
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|