Inserted row should paste in 7times in next sheet based on the date

Solved/Closed
abdul1201 Posts 2 Registration date Thursday March 5, 2020 Status Member Last seen March 5, 2020 - Updated on Mar 5, 2020 at 07:29 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Mar 9, 2020 at 12:28 PM
Hello,
i have a template and from client a workbook will i should compare and paste the data if any new row der i should insert in template file and that inserted data should also paste 7times in the same workbook and sheet name is upload.

but main problem is inserted data is in rows and in upload we should check the date creteria and paste it whr the row inserted in template file

below is the code for comparing and inserting the row in template

Sub Copy_Paste()
Application.EnableEvents = False

Dim x, y As String
Dim i, j As Integer

x = Application.GetOpenFilename()
Set wb = Workbooks.Open(x)
y = Application.GetOpenFilename()
Set ws = Workbooks.Open(y)


lrow = wb.Sheets("Input").Range("A" & Rows.Count).End(xlUp).Row
drow = ws.Sheets("Output").Range("A" & Rows.Count).End(xlUp).Row

Dim Found As Boolean

For j = 2 To lrow
Found = False
For i = 2 To drow

CC = wb.Sheets("Input").Range("A" & j)
PP = ws.Sheets("Output").Range("A" & i)
If CC = PP Then
Found = True
wb.Sheets("Input").Range("B" & i & ":" & "I" & i).Copy ws.Sheets("Output").Range("B" & i)

End If


Next
If Found = False Then
ws.Sheets("Output").Rows(j).Insert
wb.Sheets("Input").Range("A" & j & ":" & "I" & j).Copy ws.Sheets("Output").Range("A" & j)
xr = ws.Sheets("Error_Log").Range("A" & Rows.Count).End(xlUp).Row + 1
wb.Sheets("Input").Range("A" & j & ":" & "I" & j).Copy ws.Sheets("Error_Log").Range("A" & xr)




End If

Next

MsgBox "Done", vbInformation, "Completed!!!!"

End Sub


System Configuration: Windows / Chrome 80.0.3987.122
Related:

3 responses

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Mar 5, 2020 at 12:06 PM
Hi Abdul,

I would like to help you out, but I can't make any sense of your query.

Best regards,
Trowa
1
abdul1201 Posts 2 Registration date Thursday March 5, 2020 Status Member Last seen March 5, 2020
Mar 5, 2020 at 11:53 PM
if you can give your mail id i will send u the excel file and explain in detail
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Mar 9, 2020 at 12:28 PM
Hi Abdul,

I won't do that, but you can upload your file to a free file sharing site and then post the download link here. Always be careful with sensitive data.

Best regards,
Trowa
0