How to validate in code the contents of a cell?

  • Thread starter Thread starter Heather M.
  • Start date Start date
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.
 
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
 
Back
Top