Hello,
I need your help! I wanted to see if there was a way to check for duplicates before transferring data from one workbook to my master workbook. Is there a way to scan the rows of the master workbook and see if the data being transferred over is a duplicate? Here is the code I am running to copy the data to my master. Please let me know. Any suggestions will be greatly appreciated!
Sub copyFormToMaster()
Application.ScreenUpdating = False
Workbooks.Open FileName:=ThisWorkbook.Path & "\CRForm.xlsm"
Windows("CRForm.xlsm").Activate
Unload requestForm
dataB = Sheets("Database").Range("B2")
dataC = Sheets("Database").Range("C2")
dataD = Sheets("Database").Range("D2")
dataE = Sheets("Database").Range("E2")
dataF = Sheets("Database").Range("F2")
Windows("ChangeRequestMaster.xlsm").Activate
Dim nextRow As Long
Dim dataSheet As Worksheet
Set dataSheet = ThisWorkbook.Worksheets("Database")
With dataSheet
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
With .Cells(nextRow, "A")
.Value = "ID" & nextRow
End With
.Cells(nextRow, "B").Value = dataB
.Cells(nextRow, "C").Value = dataC
.Cells(nextRow, "D").Value = dataD
.Cells(nextRow, "E").Value = dataE
.Cells(nextRow, "F").Value = dataF
End With
Windows("CRForm.xlsm").Activate
ActiveWindow.Close
Application.ScreenUpdating = True
End Sub
Bookmarks