ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to validate in code the contents of a cell? (https://www.excelbanter.com/excel-programming/282112-how-validate-code-contents-cell.html)

Heather M.

How to validate in code the contents of a cell?
 
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.

patrick molloy

How to validate in code the contents of a cell?
 
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

-----Original Message-----
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.
.



All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com