Results 1 to 1 of 1

Sheet To Sheet : Consolidation Urgent requirment By Using FolderPicker

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Hyderbad
    MS-Off Ver
    Excel 2003
    Posts
    122

    Sheet To Sheet : Consolidation Urgent requirment By Using FolderPicker

    Hi All,

    Request for sheet to sheet updation into one workbook

    Like :
    Folder(Workbooks) Consoldation Sheet
    wbk_1 / wbk2 : Sheet1 To be updated CSW in Sheet1 Only
    wbk_1 / wbk2 : Sheet2 To be updated CSW in Sheet2 Only
    wbk_1 / wbk2 : Sheet3 To be updated CSW in Sheet3 Only

    Two workbook sheets to be updated in the same sheet of consoldiated CSW workbook, worked with below code but still getting and error not updated. can any one Please.

    Attached Test FILES : Samples workbook's

    Sub consolidateFromAllWbksFromSelFolder()
        Dim folpath As String
        With Application.FileDialog(msoFileDialogFolderPicker)
            .Show
            folpath = .SelectedItems(1)
        End With
        Dim fpath As String
        With Application.FileDialog(msoFileDialogFilePicker)
            .Filters.Clear
            .Filters.Add "Excel Files", "*.xlsx"
            .AllowMultiSelect = False
            .Show
            fpath = .SelectedItems(1)
        End With
        'open target file
        Dim tgtwbk As Workbook
        Set tgtwbk = Workbooks.Open(fpath)
        
        Application.DisplayAlerts = False
        Application.ScreenUpdating = False
        Dim fs As Object, srcwbk As Workbook
        Set fs = CreateObject("scripting.filesystemobject")
        Dim fol As Object
        Set fol = fs.getfolder(folpath)
        Dim f, i As Integer, HeadingsCopied As Boolean, Frow As Long, Lrow As Long, _
        NextRowInTgt As Long
        For Each f In fol.Files
            If UCase(fs.getExtensionName(f.Name)) = "XLSX" Then
                Set srcwbk = Workbooks.Open(f.Path)
                If HeadingsCopied = False Then
                        'copy with headings
                        For i = 1 To tgtwbk.Sheets.Count
                            srcwbk.Sheets(i).UsedRange.Copy tgtwbk.Sheets(i).Range("a1")
                        Next
                        HeadingsCopied = True
                Else
                        'copy without headings
                        For i = 1 To tgtwbk.Sheets.Count
                            Frow = srcwbk.Sheets(i).UsedRange.Row
                            Lrow = Frow + srcwbk.Sheets(i).UsedRange.Rows.Count - 1
                            NextRowInTgt = tgtwbk.Sheets(i).UsedRange.Rows.Count + 1
                            srcwbk.Sheets(i).Range(Frow + 1 & ":" & Lrow).Copy _
                            tgtwbk.Sheets(i).Range("a" & NextRowInTgt)
                        Next
                End If
                srcwbk.Close False 'close without saving
                Set srcwbk = Nothing
            End If
        Next
        tgtwbk.Close True
        Set tgtwbk = Nothing
        Application.DisplayAlerts = True
        Application.ScreenUpdating = True
        MsgBox "Done"
    End Sub
    CSW workbook updated manually for better understanding.(two sheets)
    Attached Files Attached Files
    Last edited by jagadeesh.rt; 10-18-2014 at 08:01 AM. Reason: Addining notes

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] [Urgent] Inserting Time sheet Data in to Master sheet Based On the Condition Using Macros.
    By kkcmania in forum Excel Programming / VBA / Macros
    Replies: 42
    Last Post: 05-17-2013, 07:56 AM
  2. [SOLVED] VBA to copy certain data from sheet into another sheet - URGENT HELP PLEASE
    By Alice21 in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 04-15-2013, 06:28 AM
  3. [SOLVED] URGENT Pls help - Copying information from sheet 1 to sheet 2 base on a match of a value
    By 5er3ne in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2012, 08:39 AM
  4. sheet 1 needs to be daily consolidation of others
    By m3site in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-17-2011, 11:34 AM
  5. [SOLVED] Multiple consolidation sheet
    By Navin in forum Excel General
    Replies: 0
    Last Post: 03-15-2006, 11:10 AM

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