Results 1 to 9 of 9

copying data from excel files in folder/subfolders

Threaded View

Hannspree copying data from excel files... 10-21-2015, 11:46 AM
skywriter Re: copying data from excel... 10-21-2015, 11:54 AM
skywriter Re: copying data from excel... 10-21-2015, 12:39 PM
Hannspree Re: copying data from excel... 10-21-2015, 12:53 PM
Hannspree Re: copying data from excel... 10-21-2015, 12:47 PM
skywriter Re: copying data from excel... 10-21-2015, 01:23 PM
Hannspree Re: copying data from excel... 10-21-2015, 01:32 PM
MarvinP Re: copying data from excel... 10-21-2015, 01:53 PM
Hannspree Re: copying data from excel... 10-22-2015, 06:22 AM
  1. #1
    Registered User
    Join Date
    02-13-2014
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    5

    copying data from excel files in folder/subfolders

    Hi Guy

    im trying to get this macro to copy data from excel files in folders it works but i need it to get data from excel files in sub-folders aswell can someone please help

    Thanks



    Sub Button18_Click()
    
        Dim StrFileName As String
        Dim FileLocnStr As String
        Dim fNum As Long
        Dim StrFile As String
    
        FileLocnStr = InputBox("Please enter your Job number here", "Digital Preflight", "p:/") 'ThisWorkbook.Path
    
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        fNum = 1
        StrFile = Dir(FileLocnStr & "\*.xls")
    
        Do While Len(StrFile) > 0
            CopyData FileLocnStr & "\" & StrFile, fNum
            StrFile = Dir
            fNum = fNum + 1
        Loop
    
        With Application
            .ScreenUpdating = True
            .EnableEvents = True
        End With
    
    
    End Sub
    
    
    Sub CopyData(StrFileName As String, fNum As Long)
        Dim Wb1 As Workbook, rngCopy As Range
        Dim rngDest As Range
    
        Set Wb1 = Workbooks.Open(StrFileName)
        Set rngCopy = Wb1.Sheets("Items").Range("A1:aq617")
        Set rngDest = ThisWorkbook.Sheets("Paste") _
                            .Range("a1")
    
        rngCopy.Copy rngDest
        With rngDest.Resize(rngCopy.Rows.Count, rngCopy.Columns.Count)
            .Value = .Value
        End With
    
        Wb1.Close False
    
    End Sub
    Last edited by Hannspree; 10-21-2015 at 11:58 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] list of subfolders in folder - without files and sub-subfolders
    By MartyZ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2022, 10:56 AM
  2. VBA that goes through all xls files in folder and subfolders
    By Acxer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-18-2015, 09:06 AM
  3. Needs macro to copy excel files from folders, subfolders to new folder
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2014, 08:53 AM
  4. [SOLVED] Reading Excel files in folder/subfolders
    By crakter in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-21-2014, 05:48 AM
  5. copying data from excel files in a source folder to target folder
    By Javed07 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2013, 04:27 PM
  6. Counting files in folder including subfolders also and folder size
    By mido609 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 03:26 PM
  7. [SOLVED] Opening Excel files in same folder through a Macro - but not subfolders?
    By toffee_madman in forum Excel General
    Replies: 9
    Last Post: 10-19-2011, 11:09 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