
Originally Posted by
p45cal
First, the attached is very basic; I leave the addition of bells and whistles to you (such as labels on the userform telling users what's required).
For others not wishing to download/open the attachment, the solution comprises a userform called userfom1 with a Date &Time Picker called DTPicker1 and a command button called CommandButton1 with the caption OK.
Then there's an activex command button on the worksheet called CommandButton1. The code in the worksheet module is:
[vba]Private Sub CommandButton1_Click()
CheckColumnC
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRange As Range
Set myRange = Intersect(Columns(3), Target)
If Not myRange Is Nothing Then CheckARange myRange
End Sub
[/vba] and code in the userform module:
[vba]Private Sub CommandButton1_Click()
UserForm1.Hide
cll.Value = Me.DTPicker1.Value
Unload Me
End Sub
Private Sub UserForm_Initialize()
Me.DTPicker1.Value = cll.Value
End Sub
[/vba] and the entire code of a standard code module:
[vba]Public cll As Range 'this line must be in the Declarations part (the top) of the module.
Sub CheckColumnC()
Set myRange = Intersect(ActiveSheet.UsedRange, Columns(3))
CheckARange myRange
End Sub
Sub CheckARange(theRange)
For Each cll In theRange.Cells
Set xxx = Range("Offdays").Find(cll.Value)
If Not xxx Is Nothing Then
cll.Select
UserForm1.Show
End If
Next cll
End Sub
[/vba]Since it is its own data validation, you can lose the cell Data Validation because it becomes messy with two mechanisms checking data.
Column E in the attachment is not needed, lose it, it was just there to show me whether dates were valid or not.
It's rough and ready but should give you the Any ideas? you wanted.