How to validate in code the contents of a cell?

H

Heather M.

I need to test the value in a cell that currently has
validation turned on values displayed in a
list (combo box)

The routine in VBA is as follows:
Private Sub Worksheet_SelectionChange(ByVal Target As
Excel.Range)
WorkID = ActiveCell().Text
If WorkID = "Flex" Then MsgBox "Please complete Flex-Time
Form"
End Sub

My problem is that it only fires when I leave the cell and
return back...How can I test the value in cell before, or
as, I get to the next cell?

This is Excel '97
Thanks,

Heather.
 
P

Patrick Molloy

Try using the worksheet's Change event instead of the
SelectionChange event. Change is fired when a value is
entered. In the parameter list 'Target' is the range that
changed, so I should recommend that you use Target.Value
in preference to Activecell.Value

Patrick Molloy
Microsoft Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top