Results 1 to 6 of 6

Processing xls files sequentially

Threaded View

  1. #1
    Registered User
    Join Date
    06-18-2009
    Location
    australia
    MS-Off Ver
    excel 2007
    Posts
    7

    Processing xls files sequentially

    Gday all,

    I use Excel 2003 at work, and 2007 at home. The wife is crook today, so im working from home... well, trying to. I have searched the net for a solution to my particular prob, but while I am ok with developing and running some macro's, im not really a power user.

    Problem:
    I understand that Application.FileSearch has been depreciated in 2007, but I cannot seem to modify other suggested codes to make workarounds work with my needs. Im hoping someone here can help

    I have a folder with a many .xls files in it, all ending in "*metrics33yrs.xls", my 2003 code (sourced from the net) opens each one sequentially (1st part of below code), copies given cells, and pastes them into a separate workbook (2nd part of below code).

    Can anyone please help with the first part of the code so that it works in 2007?

    Cheers in advance

     '---------------------------------------------------------------------------------------------------------
    
    Sub RunAllFiles_AllMetrics()
    
    Dim lCount As Long, wbResults As Workbook, wbCodeBook As Workbook
    
    Application.ScreenUpdating = False
    
    Application.DisplayAlerts = False
    
    Application.EnableEvents = False
    
    On Error Resume Next
    
    Set wbCodeBook = ThisWorkbook
    
        With Application.FileSearch
    
            .NewSearch
    
             'Change path to suit
    
            .LookIn = "E:\Work\Work\MetricResults_010908"
    
            .FileType = msoFileTypeExcelWorkbooks
    
            .Filename = "*Metrics33*.xls"
    
                If .Execute > 0 Then 'Workbooks in folder
    
                    For lCount = 1 To .FoundFiles.Count 'Loop through all.
    
                     'Open Workbook x and Set a Workbook variable to it
    
                     Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)
    
    
     '---------------------------------------------------------------------------------------------------------
    
    
    thisname = ActiveWorkbook.Name
    sitename = Split(thisname, "_")
    shname = sitename(0) & "_Totems33yrs"
    Sheets(shname).Activate
    
    ...selects and copies cells...
    
    Windows("AllMetrics_EMLR+WMLR.xls").Activate
        Select Case lCount
        Case 0 To 10
            asheet = "Sheet1"
        Case 11 To 20
            asheet = "Sheet2"
        Case 21 To 30
            asheet = "Sheet3"
        Case 31 To 40
            asheet = "Sheet4"
        Case 41 To 50
            asheet = "Sheet5"
        Case 51 To 60
            asheet = "Sheet6"
        Case 61 To 70
            asheet = "Sheet7"
        Case 71 To 80
            asheet = "Sheet8"
        Case 81 To 90
            asheet = "Sheet9"
        Case 91 To 100
            asheet = "Sheet10"
        Case 101 To 110
            asheet = "Sheet11"
        Case 111 To 120
            asheet = "Sheet12"
        
        End Select
        Sheets(asheet).Activate
        Range("a1").Select
        Selection.End(xlToRight).Select
        ActiveCell.Offset(rowOffset:=0, columnOffset:=1).Activate
    
        ActiveSheet.Paste
    Last edited by Bjornago; 06-18-2009 at 08:39 PM.

Thread Information

Users Browsing this Thread

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

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