Solved

Form property in Excel

Posted on 2014-01-21
1
190 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 48

Accepted Solution

by:
Rgonzo1971 earned 500 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now