Mooredk, that was a long time back so I'm trying to remember what I did. I did it within Access because I don't know VB. This may be a long answer because there was some extensive programming involved on the Excel end.
Maybe if I explain my spreadsheet, etc, it will help to then understand my steps.
This database was created for a real estate client, so in the database itself the main identifier for everything is the Street Address and City (both have to match).
Every day the client downloads new data from a website and we leave that as it is.
I created a NEW spreadsheet called Properties. Then I created macros to do the following:
1. CLEAR OLD DATA -- this macro clears the data in the main worksheet (also called Properties) and deletes another worksheet called Converted. That's for two reasons --
a. Obviously we want to get rid of the old data to prepare for the new.
b. Once data is pulled from the downloaded spreadsheet, I have to "clean" it, meaning it downloads with addresses abbreviated and in order to avoid duplicates I have to do a conversion to make it spell out all the addresses (EX: 123 Main St becomes 123 Main Street). Hence the worksheet called Converted. The Converted spreadsheet is where you get the correct fields and spelled out addresses for the export, but the Converted worksheet comes later in the process, so for now, it just needs to be removed, hence the Delete Converted worksheet included in the Clear Old Data macro.
2. GET NEW DATA -- this macro goes out and gets the new data from the downloaded spreadsheet and posts it into the Properties spreadsheet in the Properties worksheet. I have another worksheet that permanently resides in the Properties spreadsheet called Clean Addresses. This is where I put the formulas to change the addresses from abbreviated to spelled out, so Clean Addresses is directly linked to Properties, but only via the Street Address and City fields. The other fields in this worksheet are formulated to find the abbreviations and correct them.
But...since the new data could be 25 records or 500 records, I have to allow for up to 500 records, so my formulas always begin with -- IF(Properties!StreetAddr=" ", " ", IF(Propreties!StreetAddr<>" ", Properties!StreetAddr)).
This is so that it will "hide" those nasty #VALUE# posts in the cells where there is no data to be linked from the main worksheet Properties. This will become a necessity when exporting later.
3. CONVERT -- okay, so this macro creates a worksheet called Converted, changes the field names and data types to match those we will need for the export into Access, AND brings in the address and city correctly from the previous Clean Addresses worksheet. The rest of the data is linked to the Properties worksheet except those two fields which are linked to the Clean Addresses worksheet.
(I hope this is not TMI and that I have not confused you to this point) Please do write me back if you need help understanding or if I've overdone the explanation, whatever.
The Converted macro also creates a Named Range that will be the range that is exported into Access.
These formulas, too, all begin with -- If(Properties!Field1=" ", " ", If(Properties!Field1<> " ", Properties!Field1 --- or two or three, whatever, except you need to use the cell reference...Field1 here is just for example.
Again, that is so that when you look at the spreadsheet Converted, any data that does not exist in the main worksheet Properties won't give you those "=#Value# results. And again, this is very import for the export!
Okay, so at this point the macros have all been run, the range with corrections selected, and the spreadsheet close. Now you move on to the Access side or this monster.
First, I created a table called Properties in the database with field names and data types needed by the client.
Then I created an Access macro that includes the following:
1. Delete query to delete any current records in the Properties table.
2. Import/Export spreadsheet (created via a Saved Import)
3. Delete Null Records Query (this is where all those formulas to leave the cells blank in Excel if there was no matching data in the main worksheet comes into play. If those cells in Excel showed #Value# or anything else, they would be considered data and would not be deleted here.
4. Append query to append all the records just posted in the Properties table to the Main table.
5. Find Duplicates Query to find duplicates based on Street Address AND City.
That one macro was written as the event procedure for a button I put on the menu for the client that is called Import Property Data.
So, the client DOES have to open his spreadsheet and quickly run the three macros, which only takes seconds, then run this macro in Access and voila! all is done for him.
After writing this novel, I hope I answered your question. A lot of information, I know, but only way I knew how to explain what I did. If I can help further, let me know. Thanks! Sherry aka Hey Lucy!