Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can I use an Excel macro as a data validation rule?

Posted on 2002-04-19
5
Medium Priority
?
176 Views
Last Modified: 2010-05-02
I would like to use a macro function to validate the data entered in a cell, in Excel (like the Data validation).
Thanks,
Octi
0
Comment
Question by:octi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 6953367
Hi Octi,

What do you want to check for because everything can be done only if you can be a bit more precise it would be easier to build the code

:O)Bruintje
0
 

Author Comment

by:octi
ID: 6953385
I would like to check if the introduced name is in the address book. I have a function to do that.
0
 
LVL 44

Accepted Solution

by:
bruintje earned 400 total points
ID: 6953409
and you would trigger this function on a cell change? then something like this could help

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
  ' call to your function 'NameIsInAddressBook'
  If NameIsInAddressBook(Target.Value) Then
    Msgbox "It's OK"
    ' your code here
  Else
    Msgbox "Ÿou entered a new name"    
    ' your code here
  End If
 
End Sub

:O)Bruintje
0
 

Author Comment

by:octi
ID: 6953426
This event is OK, I tryed with SelectionChange, but the Target was wrong (new selection, instead of old). Thanks.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6953438
Great thanks for the A grade
0

Featured Post

Independent Software Vendors: 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

705 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