+ Reply to Thread
Results 1 to 4 of 4

Macro to Summarize daily files by copying blocks from daily files.

Hybrid View

  1. #1
    Registered User
    Join Date
    04-24-2012
    Location
    Minneapolis
    MS-Off Ver
    Excel 2010
    Posts
    2

    Macro to Summarize daily files by copying blocks from daily files.

    Hello Excel Experts,

    I have a humble request for some help with programming with my 'summary' file that I need to update daily from a template file. I need to copy 5 column blocks from the '05252012' file by looking up the first column in the summary file which is a part number.

    The blocks to be copied are G5:G131,L5:L131,K5:K131,J5:J131,I5:I131 from the file '05252012' and they need to be pasted to the last five available columns AD to AH. Presently I am doing Vlookups for each Part number's column block from the '05252012' array.

    The problem is I get this file created daily and the next day it would be '05262012', "05272012' and so forth, and I want to copy the same blocks without having to create Vlookups again for the new file, so I would like to program my summary file to copy the same blocks and append them to the end of the summary file so I can see a progression by day of the data.

    I would greatly appreciate some help with this problem, thank you for looking!
    Summary File.xlsxAttachment 158113
    Attached Files Attached Files
    Last edited by menoninblack; 05-25-2012 at 10:39 PM.

  2. #2
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Macro to Summarize daily files by copying blocks from daily files.

    Your 05252012.xlsx file was empty.

  3. #3
    Registered User
    Join Date
    04-24-2012
    Location
    Minneapolis
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Macro to Summarize daily files by copying blocks from daily files.

    Hi StevenM, Thanks for pointing that out, I'm such a klutz! I've updated it with the right file..

  4. #4
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Macro to Summarize daily files by copying blocks from daily files.

    Backup your data.

    'The blocks to be copied are G5:G131,L5:L131,K5:K131,J5:J131,I5:I131 from the file '05252012'
    'And they need to be pasted to the last five available columns AD to AH.
    Private Sub CopyFromBQD(wsBQD As Worksheet, wsThis As Worksheet)
        Dim nNextRow As Long
        With wsThis
            ' First time Next Row begins at row 2 (this can be fixed)
            nNextRow = .Cells(.Rows.Count, "AD").End(xlUp).Row + 1
            wsBQD.Range("G5:G131").Copy .Range("AD" & nNextRow)
            wsBQD.Range("L5:L131").Copy .Range("AE" & nNextRow)
            wsBQD.Range("K5:K131").Copy .Range("AF" & nNextRow)
            wsBQD.Range("J5:J131").Copy .Range("AG" & nNextRow)
            wsBQD.Range("I5:I131").Copy .Range("AH" & nNextRow)
            .Range("AD:AH").Columns.AutoFit
        End With
    End Sub
    
    
    Function GetExcelFileName() As String
        ChDir ThisWorkbook.Path & "\"
        GetExcelFileName = Application.GetOpenFilename( _
            FileFilter:="Excel Files (*.xls*), *.xls*,", _
            FilterIndex:=1, _
            Title:="Select An Excel File")
    End Function
    
    Sub UpdateFromDailyFile()
        Dim sFileName As String
        Dim wsThis As Worksheet
        Dim wbDaily As Workbook
        Dim wsBQD As Worksheet
           
        Set wsThis = Worksheets("Sheet3 (2)")
        sFileName = GetExcelFileName()
        If Len(sFileName) Then
            Set wbDaily = Workbooks.Open(sFileName)
            If Not wbDaily Is Nothing Then
                Set wsBQD = wbDaily.Worksheets("BQD")
                CopyFromBQD wsBQD, wsThis
                wbDaily.Close
            End If
        End If
    End Sub
    menoninblack_Summary File.xlsm

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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