I'm using several child workbooks that automatically pull data from sheet1 of a master workbook on opening.
If sheet1 of any child workbook is modified the user has the option to save the data to the master workbook.
This seems to work fine but is there a cleaner way of doing this? Preferably with no "save" option.
What I want to happen, in short... each child can be opened, it will pull data from the master database and when the child is
closed (saved or not) the master database will be automatically saved with the amended data.
To test the attached workbooks, copy both of them to your C drive or view the code below.
Child Workbook
Private Sub Auto_Open()
With GetObject("C:\Database.xlsm")
Sheets(1).[A1:Z500] = .Sheets(1).[A1:Z500].Value
.Close True
End With
End Sub
Private Sub Auto_Close()
'Update the closed database WB
Workbooks.Open "C:\Database.xlsm"
'Run macro inside external Database WB
Application.Run "Database.xlsm!UpdateDB"
Workbooks("Database.xlsm").Close savechanges:=True
End Sub
Database Workbook
Sub UpdateDB()
With GetObject("C:\Child.xlsm")
Sheets(1).[A1:Z500] = .Sheets(1).[A1:Z500].Value
.Close True
End With
End Sub
Bookmarks