|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 指定文件夹下多薄多表逐个取数()
- Dim wb As Workbook, Sht As Worksheet
- Set Sht = Sheet1
- sa = Sht.[A2]
- Sht.UsedRange.Offset(5, 0).ClearContents
- Application.ScreenUpdating = False
- f = Dir(ThisWorkbook.Path & "\销售记录\*.xls*")
- Do While f <> ""
- Set wb = Workbooks.Open(ThisWorkbook.Path & "\销售记录" & f)
- n = n + 1
- For Each sh In wb.Sheets
- m = m + 1
- For i = 2 To sh.[A1048576].End(3).Row
- If sh.Cells(i, 4) Like "*" & sa & "*" Or sh.Cells(i, 5) Like "*" & sa & "*" Then
- t = t + 1
- Sht.Cells(t + 5, 1) = wb.Name
- Sht.Cells(t + 5, 2) = sh.Name
- Sht.Cells(t + 5, 3) = i
- Sht.Cells(t + 5, 4) = sh.Cells(i, 4)
- Sht.Cells(t + 5, 5) = sh.Cells(i, 5)
- End If
- Next
- Next
- m = 0
- wb.Close False
- f = Dir
- Loop
- MsgBox "共查询了 " & n & " 个工作薄 " & n & " 个工作表 ,找到符合条件的 " & t & " 行数据 。"
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|