|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub FileDir()
Dim p$, f$, k&, temp_str$, temp_f$, d As Integer
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.xls*")
d = ThisWorkbook.Sheets(1).Range("A65536").End(xlUp).Row
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set Wb = Workbooks.Open(p & f)
For i = 1 To d
temp_f = Left(f, InStr(1, f, ".") - 1)
temp_str = ThisWorkbook.Sheets(1).Range("a" & i).Value
If temp_f = temp_str Then
Wb.Sheets(1).Range("b2") = Replace(ThisWorkbook.Sheets(1).Range("c" & i).Value, "", "")
Wb.Close True
End If
Next
End If
f = Dir
Loop
End Sub |
|