Private Sub cmdOK_Click()
Application.ScreenUpdating = False
Dim Mylrow As Long, PLLrow As Long
Dim MyDate As Date, MyVsle As String
Dim mylrow2 As Long
Dim r
Sheets("Z").Activate
Sheets("Z").Range("A1").PasteSpecial Paste:=xlPasteValues
Sheets("all dor's").Activate
Sheets("all dor's").Unprotect Password:="techedit"
Mylrow = Sheets("All DOR'S").Range("B18").End(xlDown).Row + 1
Sheets("Z").UsedRange .Copy
With UserForm4
MyDate = Calendar1.Value
For r = 0 To .lstbVessel.ListCount - 1
If .lstbVessel.Selected(r) = True Then ''get the vessle name
MyVsle = lstbVessel.List(r)
End If
Next
If IsNumeric(Application.Match(CDbl(MyDate), Range("H18:H" & Mylrow), 0)) And IsNumeric(Application.Match(MyVsle, Range("I18:I" & Mylrow), 0)) Then
If Application.Match(CDbl(MyDate), Range("H18:H" & Mylrow), 0) = Application.Match(MyVsle, Range("I18:I" & Mylrow), 0) Then
MsgBox "A DOR of the same date and vessel name has already been entered! Please select another date or a diffrent vessel."
Exit Sub
End If
End If
Sheets("All DOR'S").Cells(Mylrow, 2).PasteSpecial xlValues
'''' now det the last row form the pasted values '''
PLLrow = Sheets("All DOR'S").Range("B65536").End(xlUp).Row
'''' fill column H for Date and Column I for Vessle '''
Sheets("All DOR'S").Range("H" & Mylrow & ":H" & PLLrow).Value = MyDate '' this is for the Date
Sheets("All DOR'S").Range("I" & Mylrow & ":I" & PLLrow).Value = MyVsle
End With
Unload UserForm4
Application.DisplayAlerts = False
Sheets("Z").UsedRange.ClearContents
Sheets("all dor's").Protect Password:="techedit"
Application.DisplayAlerts = True
MsgBox "DOR data added successfully!"
End Sub