Link to home
Start Free TrialLog in
Avatar of Adam Elsheimer
Adam ElsheimerFlag for Germany

asked on

VBA - Transfer values from Master wb to all wbs. Delete old data, copy new data from master wb to user wbs located in a folder.

I came across below code.

Macros task; update a specific worksheet in all workbooks in a folder.

In a Master file there is a worksheet named  "Config". I would like transfer from this master file sheet "Config" values to user workbooks where is  a  sheet "Tabelle2". As a monthly routine I have to update this specific sheet for 30 users.

I would like add following:

1. Update all closed workbooks in a specific folder not only one workbook (delete all values in the user workbooks sheets "Tabelle2" before copying from Master "Config" the new data Range Col A: E
2. Control all the startup & save messages about updating/saving  linked workbooks
3. Close workbooks.

Sub TransferDataV2()
'transfer stuff from this workbook to workbook 2

    Dim strPath2 As String
    Dim wbkWorkbook1 As Workbook
    Dim wbkWorkbook2 As Workbook

    'define paths and filenames
    strPath2 = "C:\Users\Adam\Desktop\User_01.xlsm"

    'open files
    Set wbkWorkbook1 = ThisWorkbook
    Set wbkWorkbook2 = Workbooks.Open(strPath2)



    wbkWorkbook2.Worksheets("Tabelle2").Range("A1:E60000").Value = _
        wbkWorkbook1.Worksheets("Config").Range("A1:E60000").Value

    'close the workbook
    wbkWorkbook2.Close (True)

End Sub

Open in new window


Please find attached a Master and a User sample file.

Any assistance will be greatly appreciated.

Thank you very much.

Regards,

Adam
Master.xlsm
User_01.xlsm
ASKER CERTIFIED SOLUTION
Avatar of Shums Faruk
Shums Faruk
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Adam Elsheimer

ASKER

Shums, thank you again for you assistance. It works great. Thank you also for your quick and professional response and solution.

Please accept my apologies for the delay in responding to your solution. Unfortunately I fell asleep :-)

Best Regards,

Adam
No Worries Adam! After I replied your question, I also went to bed.

You're Welcome! Glad I was able to help.