Howdy Mike,
mrissi said:
I must be doing something wrong -- it keeps just opening the first file. It also won't close the first file, just keeps trying to re-open it.
A slightly different approach:
<font face=Courier New><SPAN style="color:darkblue">Sub</SPAN> OpnFiles()
<SPAN style="color:darkblue">Dim</SPAN> i <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>, cl <SPAN style="color:darkblue">As</SPAN> Range, wb <SPAN style="color:darkblue">As</SPAN> Workbook
<SPAN style="color:darkblue">With</SPAN> Application.FileSearch
.NewSearch
.LookIn = "D:\Total Sale Value <SPAN style="color:darkblue">Output</SPAN> All Stores\"
.Filename = ".xls"
<SPAN style="color:darkblue">If</SPAN> .Execute() > 0 <SPAN style="color:darkblue">Then</SPAN>
Application.ScreenUpdating = 0
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> .FoundFiles.Count
<SPAN style="color:darkblue">Set</SPAN> wb = Workbooks.Open(.FoundFiles(i))
<SPAN style="color:darkblue">With</SPAN> wb.Sheets(1)
.[e1:f1].Value = [{"MaxAsOfDate","WeekDay"}]
.[A:A,e:f].EntireColumn.AutoFit
.[a:b].NumberFormat = "mm/dd/yy"
.[c:c].NumberFormat = "General"
<SPAN style="color:darkblue">Set</SPAN> cl = .[a65536].End(3)
<SPAN style="color:darkblue">With</SPAN> .Range("e3", cl(, 5))
.Formula = "=IF(RC[-4]<>"""",MAX(C[-4]),"""")"
.Value = .Value
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>
<SPAN style="color:darkblue">With</SPAN> .Range("f3", cl(, 6))
.Formula = "=IF(RC[-5]<>"""",WEEKDAY(RC[-1],1),"""")"
.Value = .Value
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>
<SPAN style="color:darkblue">Set</SPAN> cl = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>
wb.<SPAN style="color:darkblue">Close</SPAN> True: <SPAN style="color:darkblue">Set</SPAN> wb = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">Next</SPAN> i
Application.ScreenUpdating = 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>
I was having trouble discerning exactly what you are trying to do here. Can't figure out why these formulae should fill as such, seems duplicative...But possibly a start... Hope this helps.