VBA button macro to update database workbook from another workbook

jonobono8888

New Member
Joined
Jan 28, 2019
Messages
14
Hi All

I have a large table in my main database workbook (“Main Database”) - worksheet named "G-XXX Material Database", which contains material codes, material properties, manufacturers, etc (Columns A-L), starting from row 3 (headers are in row 3, all the data is in a filter below that). This table was copied from another workbook (“G-Codes”) in the same folder directory.

Ideally, I’d like an “Update” button macro on my “Main Database” workbook (positioned in Cell C1) which would look at the “G-Codes” workbook table, see if there were any differences and copy and/or replace them over to my “Main Database” workbook (keeping all the same formatting as the “G-Codes” workbook).

For “G-Codes” workbook:
  • The Table is in exactly the same position as in the “Main Database”. I.e. Headers for the table are in row 3, with all the data below it. Number of columns go from A to L. Worksheet name is called “Gxxx Material data base”
  • Additionally – once things have been updated, I’d like the date at which it was updated to be published in cell B1 of “Main Database”, as well as a pop-up message saying that the table was updated successfully. I don’t want anything to happen to the “G-Codes” file at all.

I had a search around for other codes which copies data over from once workbook to another, but I couldn't find anything which checks for consistency and just replaces anything bad. Most duplicating macros just put another row below or paste it in a different sheet elsewhere which I don't want.

If someone could help me with this I'd be super grateful! Thank you! If you need more information, please let me know and I'll try and be as descriptive as possible.
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

sergioMabres

Well-known Member
Joined
Feb 24, 2013
Messages
946
Hi Jono,
I may be wrong but if you say
"see if there were any differences and copy and/or replace them over to my “Main Database” workbook (keeping all the same formatting as the “G-Codes” workbook)"
This looks just like delete values in Main Database, copy G-Codes all records, and paste values in Main Database to preserve cell formatting
I dont see any difficulty in this, you could even do it with the record macro option
Cheers
Sergio
 

Watch MrExcel Video

Forum statistics

Threads
1,109,033
Messages
5,526,373
Members
409,697
Latest member
christopherlewis1620

This Week's Hot Topics

Top