如何在多张不同的EXCEL文件中提取相同位置的数据?
发布网友
发布时间:2022-04-28 22:08
我来回答
共3个回答
热心网友
时间:2022-05-23 18:30
利用“=”号就可以,在5.xls中的A1里输入 ='1.xls'!A8 然后点击回车即可。如图:
热心网友
时间:2022-05-23 18:30
5.XSL,右键sheet1——查看代码——粘贴代码——运行代码
Sub mysub()
Dim ShApp As Object, mysheet As Object
Dim TF As Boolean, i As Integer
Dim aTable As Object, n As Integer
On Error Resume Next
n = 0
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "请选定要处理的excel文档"
.Filters.Add "excel文档", "*.xls" '暂定扩展名为xls的excel文档
.AllowMultiSelect = True
If .Show <> -1 Then Exit Sub
Set ShApp = GetObject(, "Excel.Application")
If Err <> 0 Then
TF = True
Set ShApp = CreateObject("Excel.Application")
End If
Application.ScreenUpdating = False
For i = 1 To .SelectedItems.Count
Set mysheet = ShApp.Workbooks.Open(.SelectedItems(i))
With mysheet.Sheets(1)
.[a8].copy [a65536].end(xlup).offset(1)
End With
n = n + 1
mysheet.Close True
Next i
End With
If TF = True Then ShApp.Quit
Set ShApp = Nothing
MsgBox "处理完毕,共处理了" & n & "个excel文档。"
Application.ScreenUpdating = True
End Sub
热心网友
时间:2022-05-23 18:31
当然,用VBA也是可以的,只是不会用的话也不用像楼上那么复杂。不过你要确定你这些1.xls、2.xls、3.xls、4.xls在硬盘的路径是否在同一文件夹。
如果不在同一文件夹,那还不如直接复制粘贴,因为用公式的话要输入路径。
假设都在D:\下。那么在5.xls中,A8='D:\[1.xls]Sheet1'!$A$8+'D:\[2.xls]Sheet1'!$A$8'D:\[3.xls]Sheet1'!$A$8'D:\[4.xls]Sheet1'!$A$8
这就把1.xls、2.xls、3.xls、4.xls文件中A8的数据到加起来放在5.xls中了