+ Reply to Thread
Results 1 to 18 of 18

Exporting data from master file to pre-populate many excel files from a template

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Exporting data from master file to pre-populate many excel files from a template

    Hi All,

    I've been tasked to try find a VBA solution to export certain data from a master file into a separate template, 3 files attached for reference (Master.xlsm / Template.xlsm / PS00101_North Building_072013.xlsx)

    There are 6 rows within the master file and each row represents a project (i.e. 6 projects). I'd like to export data for each project into its own template file which consists of 2 tabs "RAG" & "Financials"

    The yellow column data within the master file is to be exported into the yellow "RAG" tab in the template file and orange columns to "Financials" tab.

    The 6 populated Template files each need to be saved with the following naming convention ProjRefno_Building name_MMYYYY.xlsx and I've added the PS00101_North Building_072013.xlsx file to show how the end result would look for the first project for the month of July.
    Attached Files Attached Files
    Last edited by Gti182; 08-06-2013 at 04:34 AM.

  2. #2
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Exporting data from master file to pre-populate many excel files from a template

    Hi Giti

    for each Project ref u want separate workbook with relevant data right
    Thanks - Naveed
    -----------------------------
    If the suggestion helps you, then Click * to Add Reputation
    To Attach File: Go Advanced>>Manage Attachments>>Add Files (In Top Right Corner)>>SelectFiles>>.........Locate Your File(s)>>Upload Files>>Done (In Bottom Right)
    1. Use [code] code tags [\code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  3. #3
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Re: Exporting data from master file to pre-populate many excel files from a template

    thats right Naveed

  4. #4
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Exporting data from master file to pre-populate many excel files from a template

    Hi Gti

    try attached file

    Paste this both workbook where u want to and copy that path and paste in module & open Master File and click on button
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Exporting data from master file to pre-populate many excel files from a template

    ok i m working on same

  6. #6
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Re: Exporting data from master file to pre-populate many excel files from a template

    Thanks for the code Naveed works perfectly

    I must admit I'm having a hard time understanding what the code is doing but i will play around with it and try adapt it to my actual situation but i think i can follow your logic.

    Much appreciated!
    Last edited by Gti182; 08-06-2013 at 04:29 AM.

  7. #7
    Registered User
    Join Date
    11-17-2004
    Posts
    3

    Re: Exporting data from master file to pre-populate many excel files from a template

    Thought I'd contribute for fun...run the test method in 'Test' Standard Module.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Re: Exporting data from master file to pre-populate many excel files from a template

    Thanks vbc22 your's works perfectly too. I was curious as to how the link pairs worked?

    I'm guessing all i'd need to do is modify that section of code for my actual files as my master file has over 100 columns and the template has 21 input fields.

  9. #9
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Re: Exporting data from master file to pre-populate many excel files from a template

    Naveed i'm hoping you can help me amend your original code relating to an update made in the the "Financials" tab.

    I've included my actual amended code below and a new attachment with the "Financials" tab amended. The data from the master file needs to be exported into the template horizontally rather than vertically (per my first attached template). The "RAG" import works perfectly

    Sub Monthly_report_export()
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    PR = ActiveWorkbook.Name
    Dim sh As Worksheet
    Dim LR As Long
    Dim FR As Long
    FPath = "D:\Documents and Settings\uczbmon\Desktop\New Folder (2)"
    Set sh = Workbooks("" & PR & "").Sheets("Project Register")
    With sh
        LR = .Range("L" & .Rows.Count).End(xlUp).Row
        RAG = Array("M", "L", "F", "T", "AF", "AG", "U", "V", "AC", "Z", "AA", "P", "BO", "BQ", "BR", "BT", "BV", "BX", "BZ", "CB", "CD")
        For j = 2 To LR
        Workbooks.Open FPath & "\" & "Monthly Report Template.xlsx"
        
    MPR = ActiveWorkbook.Name
        FR = 2 'Workbooks("" & mybk & "").Sheets("RAG").Range("B" & Rows.Count).End(xlUp).Row
        'Workbooks("" & mymc & "").Sheets("Sheet1").Activate
        For i = LBound(RAG, 1) To UBound(RAG, 1)
            .Range(RAG(i) & j).Copy Workbooks("" & MPR & "").Sheets("RAG Status").Range("B" & FR)
                
                FR = FR + 1
            Next
            'Workbooks("" & mybk & "").Sheets("RAG").Range("A9").EntireRow.Insert shift:=xlDown
            FR = 2
        FIN = Array("BL", "BM", "BN", "BD", "BG")
        For k = LBound(FIN, 1) To UBound(FIN, 1)
            .Range(FIN(k) & j).Copy Workbooks("" & MPR & "").Sheets("Financials").Range("B" & FR)
            
            FR = FR + 1
        Next
        ActiveWorkbook.SaveAs FileName:=FPath & "\" & .Range("L" & j) & "_" & .Range("M" & j) & ".xls", FileFormat:=xlExcel8
        ActiveWorkbook.Close False
        Next
    End With
    MsgBox "Done ! " & "File Saved Here - " & FPath, vbInformation
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    End Sub
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Exporting data from master file to pre-populate many excel files from a template

    Hi Gti

    Try the attached workbook and let me know is it what your looking for.

    Note: Paste this both attached file in one folder and open the master v2 file and run the macro.

    If you are agree and satisfied with solution then please click on Add Reputation below to the post left side
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Re: Exporting data from master file to pre-populate many excel files from a template

    Thanks Naveed, code works perfectly for the template v2 but struggling to modify below bit of code relating to the financials tab for my actual file but i'll play around with it a bit and try figure it out.

    Columns "L", "M" & "N" need to export to cells C17, D17 & E17
    and Columns "J" & "K" need to export to cells B22 & C22 in financials tab

            FR = 3
            FR1 = 4
        fin = Array("L", "M", "N", "J", "K")
        For k = LBound(fin, 1) To UBound(fin, 1)
            .Range(fin(k) & j).Copy Workbooks("" & mybk & "").Sheets("Financials").Cells(FR1, FR)
            If FR = 5 Then
                FR = 3
                FR1 = FR1 + 3
            Else
                FR = FR + 1
            End If

  12. #12
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Exporting data from master file to pre-populate many excel files from a template

    Just change that red color 4 to 17 and red color 3 to 5
            FR = 3
            FR1 = 4    fin = Array("L", "M", "N", "J", "K")
        For k = LBound(fin, 1) To UBound(fin, 1)
            .Range(fin(k) & j).Copy Workbooks("" & mybk & "").Sheets("Financials").Cells(FR1, FR)
            If FR = 5 Then
                FR = 3
                FR1 = FR1 + 3
            Else
                FR = FR + 1
            End If
    Please if you agree and satisfied with the solution then click on Add Reputation below to the post left side
    Last edited by Naveed Raza; 08-07-2013 at 07:13 AM.

  13. #13
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Exporting data from master file to pre-populate many excel files from a template

    Ok i give me some time right now i am in office , i will get back to u very shortly within 20mins

  14. #14
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Re: Exporting data from master file to pre-populate many excel files from a template

    Thanks again Naveed, the correct data from the master file is being exported to the template fine but the data for "J" and "K" each need to move one cell to the left i.e. starting in column B cell B22 and C22

    is there a way to keep the cell formatting of the template as currently copying the format from the master file?

  15. #15
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Exporting data from master file to pre-populate many excel files from a template

    Ok sure , i will give another updated version wait for 10mins i am working on this

  16. #16
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Exporting data from master file to pre-populate many excel files from a template

    Now try this attached version3 files and let me know

    if its meet your requirement 100% then click on Add Reputation below to the post left side
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Re: Exporting data from master file to pre-populate many excel files from a template

    You are a machine Naveed ! Works exactly how i was hoping it would. Much appreciated.

    Added to your reputation!

  18. #18
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Exporting data from master file to pre-populate many excel files from a template

    Glad to here Gti182, i am very happy by helping you. its happen only because of your good and systematic explanation the credits goes to you Gti182.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Auto copy data from other Excel files to master file...
    By NeoNirav in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-14-2013, 12:13 AM
  2. Vlookup query : How to pull data from raw excel files into a master excel file?
    By jamesjamesiata in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-22-2013, 06:26 AM
  3. [SOLVED] Import data from excel files to append master file
    By kdawgpl9 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2013, 04:32 PM
  4. Macro to populate a word template and feed an excel master sheet
    By hieldy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2013, 05:40 AM
  5. Replies: 1
    Last Post: 03-13-2012, 09:45 AM

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