|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub aaa()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Set Tb = ThisWorkbook
Set sh = Tb.Sheets("sheet1")
sh.[a2:b10000].Clear
mp = Tb.Path & "\工作表\"
mf = Dir(mp & "*.xls*")
Do
Set dk = Workbooks.Open(mp & mf)
Set sht = dk.Sheets("sheet1")
r1 = sht.[a65536].End(3).Row
r2 = sh.[a65536].End(3).Row + 1
For Each Rng In sht.Range("a1:a" & r1)
If Rng.Value = "姓名" Then sh.Cells(r2, 1) = Rng.Offset(0, 1).Value
If Rng.Value = "总分" Then sh.Cells(r2, 2) = Rng.Offset(0, 1).Value
Next Rng
dk.Close
mf = Dir
Loop While mf <> ""
Tb.Save
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub |
|