如何从多个Excel文件中提取指定单元格数据
1个回答
2017-02-07 · 互联网+时代高效组织信息化平台
关注
展开全部
Set SH0 = Worksheets("Sheet1")
SH0.Range("A2:C65536").ClearContents
IROW = 2
FileArr = FileAllArr(ThisWorkbook.Path & "", "*.xls?", ThisWorkbook.Name, True, False)
For I = 0 To UBound(FileArr)
Set WB = Workbooks.Open(FileArr(I), CorruptLoad:=xlExtractData) '//打开工作簿
Set SHX = WB.Worksheets(1)
SH0.Cells(IROW, 1) = GetPathFromFileName(FileArr(I), False)
SH0.Cells(IROW, 2) = SHX.Range(SH0.Cells(1, 2))
SH0.Cells(IROW, 3) = SHX.Range(SH0.Cells(1, 3))
IROW = IROW + 1
WB.Close False '//保存
Next
复制代码
SH0.Range("A2:C65536").ClearContents
IROW = 2
FileArr = FileAllArr(ThisWorkbook.Path & "", "*.xls?", ThisWorkbook.Name, True, False)
For I = 0 To UBound(FileArr)
Set WB = Workbooks.Open(FileArr(I), CorruptLoad:=xlExtractData) '//打开工作簿
Set SHX = WB.Worksheets(1)
SH0.Cells(IROW, 1) = GetPathFromFileName(FileArr(I), False)
SH0.Cells(IROW, 2) = SHX.Range(SH0.Cells(1, 2))
SH0.Cells(IROW, 3) = SHX.Range(SH0.Cells(1, 3))
IROW = IROW + 1
WB.Close False '//保存
Next
复制代码
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询