Below is the code I currently have that opens all the files that end in .xls in the path. However this does not seem to work in excel 2007. Any suggestions on how to change this to work on 2007?
With Application.FileSearch
.NewSearch
'Change path to suit
.LookIn = "U:\Rotations\" & ZoneDate
.FileType = msoFileTypeExcelWorkbooks
'Optional filter with wildcard
.FileName = "* Rotation.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)
wbExport = ActiveWorkbook.Name
LR = Range("A" & Rows.Count).End(xlUp).Row
Windows(wbExport).Activate
LR = Range("A" & Rows.Count).End(xlUp).Row
TryAgain:
If Err.Number = 91 Then
Err.Clear
Cnt = Cnt + 1
Workbooks("Master.xls").Sheets("Locations").Range("AA" & Cnt).Value = ActiveWorkbook.Sheets(1).Range("A3").Value
GoTo ExitHere:
End If
If Err = 91 Then GoTo TryAgain
Range("B3:B" & LR).find(What:="A", LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If Err = 91 Then GoTo TryAgain
Location = ActiveCell.Value
ItemNumber = ActiveCell.Offset(, -1).Value
Windows(MasterWB).Activate
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("A" & LR + 1)
.Value = ItemNumber
Calculate
.Value = .Value
End With
With Range("B" & LR + 1)
.Value = Location
Calculate
.Value = .Value
End With
ExitHere:
Call unmerge
wbResults.Close savechanges:=False
Next lCount
End If
End With
Bookmarks