Thank you for your help. Your coding is more elaborated than mine, I will try
them, I am still a beginner.
Last night I finally solved it. Here are the working codes:
Private Sub UserForm_initialize()
Call RangeSelection
cboDeleteCow.RowSource = "Options"
cboDeleteCow.BoundColumn = 1
cboDeleteCow.ColumnCount = 1
Worksheets("EnterCowData").Activate
CmyLastRow = LastCell(Worksheets("EnterCowData")).Row
CmyRange = "A3: A" & CmyLastRow
Application.ScreenUpdating = True
End Sub
Private Sub cboDeleteCow_Click()
Set CowListStart = Worksheets("EnterCowData").range("A3")
CowID = cboDeleteCow.Value
i = 0
Do Until i = CmyLastRow + 1
If CowListStart.Offset(i, 0).Value = CowID Then
DeleteRange = "A" & CowListStart.Offset(i, 0).Row
End If
i = i + 1
Loop
End Sub
Private Sub cmdProblemDelete_Click()
message = "Are you sure you want to delete cow " & CowID & "?"
If MsgBox(message, vbQuestion + vbYesNo, _
"Confirm Delete") = vbYes Then
' Delete current row:
Worksheets("EnterCowData").Activate
range(DeleteRange).EntireRow.Delete
End If
'reset the range
Call RangeSelection
End Sub