Sub SuperVisorFillIn()
Dim i As Integer, wb As Workbook, LR As Long
Range("A2", Range("B2").End(xlDown)).Sort Key1:=Range("A2"), _
Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
ActiveWorkbook.Names.Add Name:="Super", RefersToR1C1:="=Sheet1!R2C1:R" & Range("B" & Rows.Count).End(xlUp).Row & "C2"
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\All Users\Documents\My Documents\Excel Tips\Test"
.SearchSubFolders = False
.Filename = "Agent Call Report*.xlsx"
.Execute
For i = 1 To .FoundFiles.Count
'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))
'Perform the operation on the open workbook
Range("G1") = "Supervisor"
Columns("G:G").Columns.AutoFit
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("G2:G" & LR).FormulaR1C1 = "=VLOOKUP(RC1,'Master Database.xls'!Super,2,FALSE)"
Columns("G:G").Value = Columns("G:G").Value
'Save and close the workbook
wb.Save
wb.Close
Next i
End With
End Sub
Can anyone help me to run this code in Excel 2007 ? This code is working fine in MS Excel -2003. But when i run it in Excel 3007 it gives error stating ""Run-time error '445': Object doesn't support this action". when i press debug its comes on here "With Application.FileSearch" which is marked yellow. Excel 2007 doent support this function.
Can anyone help me regarding this ?? What i actually want to do with code is posted in the forum. the link is
http://www.excelforum.com/excel-prog...workbooks.html
Bookmarks