Dear Experts
VBA code required to Export Data from Excel to Access
I have a table in excel with 5 columns that I want to export to an access database.
The data in excel is per below and all the 5 columns exist with the same heading names in the access database.
The table name in the database is “Key_Statistics”
The database locations is C:\Users\John\KPI_Test.accdb
I also want make sure that if there is a existing record for an ID then update, if there is a new record then ADD it to the table.
Note I am using MS Excel and Access 2016
Would appreciate your help with what VBA code can help me with this.
[TABLE="width: 522"]
<colgroup><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]ID[/TD]
[TD]product[/TD]
[TD]sales_revenue[/TD]
[TD]Cost[/TD]
[TD]Profit[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]PN1[/TD]
[TD]pens[/TD]
[TD] 200[/TD]
[TD] 150[/TD]
[TD] 50[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]LP2[/TD]
[TD]laptops[/TD]
[TD] 500[/TD]
[TD] 375[/TD]
[TD] 125[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]PR3[/TD]
[TD]printers[/TD]
[TD] 200[/TD]
[TD] 155[/TD]
[TD] 45[/TD]
[/TR]
</tbody>[/TABLE]
VBA code required to Export Data from Excel to Access
I have a table in excel with 5 columns that I want to export to an access database.
The data in excel is per below and all the 5 columns exist with the same heading names in the access database.
The table name in the database is “Key_Statistics”
The database locations is C:\Users\John\KPI_Test.accdb
I also want make sure that if there is a existing record for an ID then update, if there is a new record then ADD it to the table.
Note I am using MS Excel and Access 2016
Would appreciate your help with what VBA code can help me with this.
[TABLE="width: 522"]
<colgroup><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]ID[/TD]
[TD]product[/TD]
[TD]sales_revenue[/TD]
[TD]Cost[/TD]
[TD]Profit[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]PN1[/TD]
[TD]pens[/TD]
[TD] 200[/TD]
[TD] 150[/TD]
[TD] 50[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]LP2[/TD]
[TD]laptops[/TD]
[TD] 500[/TD]
[TD] 375[/TD]
[TD] 125[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]PR3[/TD]
[TD]printers[/TD]
[TD] 200[/TD]
[TD] 155[/TD]
[TD] 45[/TD]
[/TR]
</tbody>[/TABLE]