|
楼主 |
发表于 2018-4-18 15:41
|
显示全部楼层
- Set SHX = Worksheets("汇总")
- SHX.Range("A5:HZ1048576").ClearContents
-
- Rem 获取各个分表清单
- FileArr = FileAllArr(ThisWorkbook.Path, "*.xls?", ThisWorkbook.Name, True, False)
- ICINT = UBound(FileArr) + 1
- For I = 0 To UBound(FileArr)
- Rem 提示信息,在状态栏显示
- Application.StatusBar = "文件总数:" & ICINT & " 当前是第:" & I + 1 & " 当前提取的文件是:" & GetPathFromFileName(FileArr(I), True) '
- DoEvents
-
- Rem 打开分表
- Set WB = Workbooks.Open(FileArr(I))
- Rem 找到对应表格
- For Each SH In WB.Worksheets
- If SH.Name = SHX.Range("B1").Value Then
- Rem 写入文件名
- SHX.Cells(I + 5, 1).Value = GetPathFromFileName(FileArr(I))
- Rem 找到需要的单元格位置
- For ICOL = 2 To SHX.Range("HZ4").End(xlToLeft).Column
- If Len(SHX.Cells(3, ICOL).Value) > 0 Then
- SHX.Cells(I + 5, ICOL).Value = SH.Range(SHX.Cells(3, ICOL).Value).Value
- End If
- Next
- Exit For
- End If
- Next SH
- WB.Close False
- Set WB = Nothing
- Next I
-
复制代码 |
|