Hello:
Please refer to attached file.
I have 2 sheets "Daily_Receipt" and "Clock-In-Out".
I will have data coming in "Daily_Receipt" and i am suing vb code below to copy and paste the data
at the last row of Clock-In_Out sheet.
I need to check if the same data exist then overwrite the previous data.
Currently it is adding the data although pasting the same data.
Please help me modify the code the accomplish this task.
Basically would need to check date A2 in Daily_Sheet and see if same data exist in Clock-In-Out sheet and if it exist then
make that the last row and paste the data from Daily_Receipt.
Let me know if you have any questions.
Thanks.
Riz
Sub CopyAndPasteData()
Dim wSh1 As Worksheet, wSh2 As Worksheet, nEndRw As Long
Dim xlRng As Range
Set wSh1 = Sheets("Clock-IN-OUT")
Set wSh2 = Sheets("Daily_Receipt")
Set xlRng = wSh1.Columns(1).Find(What:=CDate(wSh2.Range("O1").Value), LookIn:=xlFormulas, LookAt:=xlWhole)
If Not xlRng Is Nothing Then
If vbNo = MsgBox("Date Exist." & vbLf & "Do you want to copy?", vbYesNo + vbQuestion, "Copy") Then
Exit Sub
End If
End If
nEndRw = wSh2.Cells(Rows.Count, "A").End(xlUp).Row
wSh2.Range("A2:D" & nEndRw).Copy wSh1.Cells(Rows.Count, "A").End(xlUp)(2)
End Sub
Bookmarks