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

I would like to use a macro function to validate the data entered in a cell, in Excel (like the Data validation).
Thanks,
Octi
octiAsked:
Who is Participating?
 
bruintjeCommented:
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
 
bruintjeCommented:
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
 
octiAuthor Commented:
I would like to check if the introduced name is in the address book. I have a function to do that.
0
 
octiAuthor Commented:
This event is OK, I tryed with SelectionChange, but the Target was wrong (new selection, instead of old). Thanks.
0
 
bruintjeCommented:
Great thanks for the A grade
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.