I have the below VBA code attached to a command button on a user form. The user form has two combo boxes and two text boxes. The user selects a name from combo box 5 and based on that selection, the text box called (txteuidrecord) populates with that names unique ID number that is in column "A" of each worksheet. The user selects from combo box 6 the worksheet that they want to apply this information to and then in text box "txtrecorddate", the user enters a date. Once everything has been selected and entered, the user clicks on an add button on the user form and the code selects the worksheet listed in combobox5, find the unique ID value in column "A" that's in the txteuidrecord field, and then finds the next empty cell within that row and adds the date listed in txtrecorddate. this code works great and does what I want it to do. But I need to modify it to do two more things and I am having trouble doing so.

I would like it to first check the row for that date before it adds it, and if found, do nothing and have a message box that states "Date already on file", if not found then add the date.

I then need it to also once the date has been added, to sort that row columns E through Z in order.


Private Sub cmdaddrecord_Click()

Dim lngLastRow As Long

WS = Me.ComboBox6.Value

    If Me.combobox5.Value = "" Then
    MsgBox "Please select associate", vbExclamation, "Associate Records"
    Me.combobox5.SetFocus
    Exit Sub
 End If
 
 If Me.ComboBox6.Value = "" Then
    MsgBox "Please select record type", vbExclamation, "Associate Records"
    Me.ComboBox6.SetFocus
    Exit Sub
 End If
 
 If Me.txtrecorddate.Value = "" Then
    MsgBox "Please enter date", vbExclamation, "Associate Records"
    Me.txtrecorddate.SetFocus
    Exit Sub
 End If


lngLastRow = Worksheets(WS).Range("a1000").End(xlUp).Row
For Each c In Worksheets(WS).Range("A2:A" & lngLastRow)
     If c.Value = txteuidrecord Then
     c.Offset(0, c.End(xlToRight).Column).Value = Me.txtrecorddate.Value
     Exit For
    End If
Next
    

MsgBox ("Associate record has been added")

For Each ctl In Me.Controls
    If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Or TypeName(ctl) = "DTpicker1" Then
        ctl.Value = ""
    ElseIf TypeName(ctl) = "CheckBox" Then
        ctl.Value = False
       End If
Next ctl


End Sub