billy60
Prevent Duplicate Customer Names
Is it like that simple?
If you are managing Appointment not to overwrap for the Customer then
1)
Insert bold lines in "Sub Appt_SaveUpdate"
End If
Dim s
s = AppExists(Schedule.[e3], Schedule.[e5], Schedule.[e6], Schedule.[e7])
If s <> "" Then MsgBox "Appoint overwrapping" & vbLf & s, vbCritical: Exit Sub
Appts.Range("B" & ApptRow).Value = .Range("B12").Value 'Set Contact ID
2) Add below to the same code module
Function AppExists(sName, sDate, sTime, eTime) As String
Dim x, i As Long
With Appts.[a3].CurrentRegion
x = Filter(Appts.Evaluate("transpose(if((" & .Columns(3).Address & "=""" & sName & """)*" & _
"(" & .Columns(4).Address & "=" & CLng(sDate) & "),row(1:" & .Rows.Count & ")))"), False, 0)
If UBound(x) = -1 Then Exit Function
For i = 0 To UBound(x)
If ((sTime >= .Cells(x(i), 5)) * (sTime <= .Cells(x(i), 6))) + _
((eTime <= .Cells(x(i), 5)) * (eTime <= .Cells(x(i), 6))) Then
AppExists = AppExists & vbLf & Join(Array(.Cells(x(i), 4).Text, _
.Cells(x(i), 5).Text, .Cells(x(i), 6).Text))
End If
Next
End With
End Function
3)
Also can the customer selection drop down be in last name alphabetical order please?
Add following lines in Schedule Worksheeet_Activate event procedure.
With [e3]
.Validation.Delete
.Validation.Add 3, Formula1:=Join([transpose(unique(sortby(cont_name,mid(cont_name,find(" ",cont_name)+1,len(cont_name)))))], ",")
End With
All above is assuming your other part of codes are all working correctly.
Bookmarks