|
最后加一句删除空行的。- Sub 导入文件()
- Application.ScreenUpdating = False
- Dim filename, wb As Workbook, Sht As Worksheet, sh As Worksheet
- filename = Dir(ThisWorkbook.Path & "\子表格\*.xls")
- Set sh = ActiveSheet
- sh.[a2:b65536].ClearContents
- Do While filename <> ""
- fn = ThisWorkbook.Path & "\子表格" & filename
- Set wb = Workbooks.Open(fn)
- Set Sht = wb.Worksheets("银联")
- Set xrng = Sht.UsedRange.Find("制表", lookat:=xlPart)
- If Not xrng Is Nothing Then
- r1 = xrng.Offset(-2, 0).Row: n = r1 - 4 + 1
- r = sh.[a65536].End(3).Row + 1
- sh.Cells(r, 1).Resize(n, 1) = filename
- sh.Cells(r, 2).Resize(n, 1) = Sht.Cells(4, xrng.Column).Resize(n, 1).Value
- End If
- wb.Close False
- filename = Dir
- Loop
- Set Sht = Nothing
- sh.Range("b:b").SpecialCells(xlCellTypeBlanks).EntireRow.Delete shift:=xlUp
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
查看全部评分
|