Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Form property in Excel

Posted on 2014-01-21
1
Medium Priority
?
240 Views
Last Modified: 2014-01-22
I'm wondering if I can set a datavalidation for the text fields in a form in Excel.  I want the first text field is always 9 charactors (Can't more and can't less than 9) and the second one is date field (must enter a valid date).
0
Comment
Question by:jjxia2001
1 Comment
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39799205
Hi,

pls try

Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If Len(TextBox1.Text) <> 9 Then
    MsgBox "Error"
    Cancel = True
Else
    ' Do what is to be done
End If
End Sub


Private Sub TextBox2_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If IsDate(TextBox2.Text) Then
     ' Do what is to be done
Else
    MsgBox "Error"
    Cancel = True
End If
End Sub

Open in new window

Regards
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question