You are here:

Excel/Append download to existing table, ignoring dups



VBA is fine.

I need to append user downloads from a POS back office system to an existing table ensuring dups are removed.

I believe the download will be very dumb  (I dont have sample data yet), that is, no system created record number or system number to use to create uniqueness.

I have seen the concept of concatenating all the fields to create uniqueness and this is fine to use here.

So, to recap.

I will open Excel, press button, it will prompt me for file (CSV) and/or grab the latest date stamp file from same path, it will append to my table and then remove dups.

Table will be used for other things such as pivot table, etc.

Now what about this idea and using the code above. If the POS table is a dbf and I can read from it directly, what about an automated process that appends to my table on a schedule.  No human interaction.

Eventually, this is probably gonna go to a Office365 sharepoint table and using Access I will create the reports I need.

Let me know what you think.



Here is code to put up a file open dialog to allow the user to select a file and then it is opened.  

 Dim vNames as Variant

 sPath = "C:\Myfolcer\MySubFolder\"
 ChDrive sPath
 ChDir sPath
 vName = Application.GetOpenFilename("CSV files (*.csv), *.csv", _
         Title:="Select file you need", _
  If TypeName(vNames) = "Boolean" Then Exit Sub  ' cancelled

  Workbooks.Open vName

Now that the data is in new workbook, you can write code to identify duplicates and so forth.   When you find a duplicate delete that row in one workbook or the other.  When done, you can copy the new data and paste it adjacent to the existing data.

Pulling the latest date stamp file could be done as well.  

As far as reading a dbf, I don't believe excel has support for that anymore, but you might be able to get code off the internet to do it.  

You could use the windows timer to schedule an excel file to be opened at a certain time and run the code to do what you want describe.

Tom Ogilvy  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 All rights reserved.