Results 1 to 9 of 9

VBA to Copy data from multiple workbook to a master sheet

Threaded View

  1. #1
    Registered User
    Join Date
    04-03-2015
    Location
    Trivandrum
    MS-Off Ver
    2007
    Posts
    5

    VBA to Copy data from multiple workbook to a master sheet

    Hi,

    Does any one help me to get a vba code that meets the below mentioned requirements,

    I want to copy certain rows from different workbook to a master copy, but the criteria for the selection of row from the work books is based on the date entered on the left most cell of the rows . and all work books follow the uniform structure. It would be great if I could enter a date in the input box and then the macro copy the rows with that particular date in the left most column. Please find below the snapshot of the work book that needs to be copied.

    Date	        work type 1	work type 2	work type 3	work type 4	work type 5
    14-Jan-15	     14	             15	              16	             14	            14
    15-Jan-15	      36	             37	               45	              32	            11
    I got a vba code that partially fills my requirement. But that requires manually editing of the range in the macro code. Seems a message box to enter either the the range or the date , and the macro runs based on the inputs will fulfill my requirement.

    Sub Import_to_Master()
        Dim sFolder As String
        Dim sFile As String
        Dim wbD As Workbook, wbS As Workbook
         
        Application.ScreenUpdating = False
        Set wbS = ThisWorkbook
        sFolder = wbS.Path & "\"
         
        sFile = Dir(sFolder)
        Do While sFile <> ""
             
            If sFile <> wbS.Name Then
                Set wbD = Workbooks.Open(sFolder & sFile) 'open the file; add condition to
                 
                 ' >>>>>> Adapt this part
                wbD.Sheets("Sheet1").Range("A3:H3").Copy
                wbS.Activate
                Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
                Application.CutCopyMode = False
                 ' >>>>>>
                wbD.Close savechanges:=True 'close without saving
            End If
             
            sFile = Dir 'next file
        Loop
        Application.ScreenUpdating = True
    End Sub

    Thanking you in advance,

    Regards,

    Lijith
    Last edited by JBeaucaire; 07-11-2015 at 10:56 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 12
    Last Post: 07-29-2014, 01:06 PM
  2. Copy data from multiple workbooks to one master workbook
    By kevinvanberkel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2014, 12:26 PM
  3. [SOLVED] Consolidate Data from 1 Range on 1 Sheet in Multiple Workbooks to Master Workbook Sheet
    By Jennasis in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2013, 06:11 AM
  4. Copy Data from multiple workbooks to a master Workbook
    By zeeez in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-04-2012, 01:45 PM
  5. [SOLVED] Search for heading in data sheet and copy range to corresponding sheet in master workbook
    By sans in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-07-2012, 10:02 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