arihan1511
New Member
Code:
Private Sub CommandButton25_Click()
Worksheets("OPD").AutoFilterMode = False
Dim lastRow As Long
Dim FoundCell As Range
Dim Search As String
Search = VisitDate.Value
Set FoundCell = Sheets("OPD").Columns(1).Find(Search, _
LookIn:=xlValues, _
LookAt:=xlWhole)
If Not FoundCell Is Nothing Then
MsgBox "Duplicate Record Found in Database", vbInformation, "Database"
Exit Sub
Else
'Dim lastrow As Long
lastRow = Range("A" & Rows.Count).End(xlUp).EntireRow.Offset(1, 0).Select
UpdateData
MsgBox "Record Saved in Database", vbInformation, "Database"
'MsgBox Search & Chr(10) & "Record Not Found", 48, "Not Found"
End If
End Sub
Above code is not working for searching matching date in column A.When I hit save button it keeps on adding records to last empty Rows creating duplicate records even when VisitDate value is unchanged
I have attached file for reference