Dynamically adding fields from temp table to perm table if dont exist

RCBricker

Well-known Member
Joined
Feb 4, 2003
Messages
1,560
I have a table that I created with the first import of a report from my client. The issue is that the # of fields change every month (growing and shrinking ::SMH) as well as new field names appearing at random months and old ones coming and going. Unfortunately, the client knows and is not doing anything to standardize the uploads.

My question is:

Is there a way to upload the file to a temp table and then have vba match fields with the same name, and ADD fields that do not exist?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
This page helps with vba for changing table structure with code:
Microsoft Access tips: DAO Programming Code Examples

As far as loading to a temp table you can just pull the data into a new table and it gets the field names as they are in the "file" (excel?). Be careful that the data import is clean - blanks, mixed data types, alphanumerics can all be trouble.
 
Upvote 0
This page helps with vba for changing table structure with code:
Microsoft Access tips: DAO Programming Code Examples

As far as loading to a temp table you can just pull the data into a new table and it gets the field names as they are in the "file" (excel?). Be careful that the data import is clean - blanks, mixed data types, alphanumerics can all be trouble.

The temp table is used to update existing table. The only time new tables are created is when a new data source is added.

Thanks for the link.
 
Upvote 0

Forum statistics

Threads
1,221,814
Messages
6,162,135
Members
451,744
Latest member
outis_

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top