I have several Excel files that are in the same format, but with unique data. I would like to upload the data to a central file once a month. I have created the below macro in each of the files to append the data to the central "master" file. It works well, but I would like to add code so that it will not duplicate data, but replace it with the latest values if the file had already been submitted. In the individual files, each row of data has a unique value in column A. It would be ideal if the macro would replace the line item in the central "master" file if the unique value was already present. Does anyone have any ideas on how to modify my macro code to do this?
Sub Master_DSC_Upload()
' Master_DSC_Upload Macro
' Uploads Input data from each month's file into the DSC Master File. *Note that the location of the DSC Master File is located in cell L8 of the "Intro" tab.
Dim wbk As Workbook
Dim lRow As Long
Dim jRow As Long
Dim iCol As Integer
Dim ws As Worksheet
strSecondFile = Sheets("Intro").Range("L8").Value
ThisWorkbook.Sheets("Input").Select
Range("A2:AY466").Select
Selection.Copy
Set wbk = Workbooks.Open(strSecondFile)
wbk.Sheets("Master_Input").Select
iRow = 0
For iCol = 1 To 256
jRow = Cells(Rows.Count, iCol).End(xlUp).Row
If Cells(jRow, iCol).Value = "" Then
jRow = 0
End If
If jRow > iRow Then
iRow = jRow
End If
Next iCol
Range("A" & iRow + 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Windows("Daily Schedule Control Master File.xlsm").Close SaveChanges:=True
ThisWorkbook.Activate
End Sub
Bookmarks