Hi,
I have been trying to write a change event procedure that looks at a range of cells and checks on whether the cell = "On Hire Previous Year" or is between a date range (Named Cells FYSD and FYED). If either are TRUE then to move to the next cell and if FALSE display a message box.
I have tried different approaches but cannot seem to get it to work..could you please help with my latest attempt below and advise on some changes that I could make to get it to work..any help as always is appreciated. Thanks in advance.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Dim Cell As Range
Set Rng = Range("G4:G60")
For Each Cell In Rng
If Cell.Value <> "" And Cell.Value = "On Hire Previous Year" Then
If Cell.Value <> "" And Cell.Value < Sheets("Summary").Range("FYSD").Value Or Cell.Value > Sheets("Summary").Range("FYED").Value Then
MsgBox "Invalid Entry"
End If
End If
Next
End Sub
I have been trying to write a change event procedure that looks at a range of cells and checks on whether the cell = "On Hire Previous Year" or is between a date range (Named Cells FYSD and FYED). If either are TRUE then to move to the next cell and if FALSE display a message box.
I have tried different approaches but cannot seem to get it to work..could you please help with my latest attempt below and advise on some changes that I could make to get it to work..any help as always is appreciated. Thanks in advance.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Dim Cell As Range
Set Rng = Range("G4:G60")
For Each Cell In Rng
If Cell.Value <> "" And Cell.Value = "On Hire Previous Year" Then
If Cell.Value <> "" And Cell.Value < Sheets("Summary").Range("FYSD").Value Or Cell.Value > Sheets("Summary").Range("FYED").Value Then
MsgBox "Invalid Entry"
End If
End If
Next
End Sub