Results 1 to 1 of 1

Parent child workbooks auto updating each other, cleaner way of doing this? Attached

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-19-2010
    Location
    UK.
    MS-Off Ver
    Excel 2007
    Posts
    142

    Parent child workbooks auto updating each other, cleaner way of doing this? Attached

    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
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1