Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

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
0
octi
Asked:
octi
  • 3
  • 2
1 Solution
 
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
 
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
 
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.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now