用Exce读取另一个EXCEL文档的内容

更新时间:2024-07-02 04:06:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

Exce读取另一个EXCEL文档的内容

Sub YANG()

Workbooks.Open ThisWorkbook.Path & \打开同目录下文件 Sheets(\②Count Table\

Workbooks(\②Count Table\拷贝数据

ActiveWorkbook.Close = True '关闭A.xlsx

End Sub

Sub aa()

Workbooks.Open ThisWorkbook.Path & \打开同目录下文件 Sheet1.Range(\

Workbooks(\拷贝数据 ActiveWorkbook.Close = True '关闭A.xlsx End Sub

追问

Sub YANG()

Workbooks.Open ThisWorkbook.Path & \打开同目录下文件 Sheets(\②Count Table\

Workbooks(\②Count Table\拷贝数据

ActiveWorkbook.Close = True '关闭A.xlsx

End Sub

朋友帮我看看吧,我只改了一部分代码,提示缺少函数或变量?

Sub 数据提取()

Set fn = Application.FileDialog(msoFileDialogOpen) With fn

.AllowMultiSelect = True '允许多选 .Show End With

If fn.SelectedItems.Count = 0 Then MsgBox \没有选择任何文件\ Exit Sub End If

For i = 1 To fn.SelectedItems.Count

If fn.SelectedItems(i) Like \ Then '检测是否Excel文档

Application.ScreenUpdating = False '关闭屏幕刷新

Set wb = Workbooks.Open(fn.SelectedItems(i)) '打开选中的文件

'下面这行代码,将选中的文件第一个工作表的A1:C10区域复制到本工作簿的第一个工作表中。

wb.Sheets(1).Range(\).Copy ThisWorkbook.Sheets(1).Cells(ThisWorkbook.Sheets(1).[a65536].End(3).Row + 1, \) wb.Close '关闭打开的文件

Application.ScreenUpdating = True '打开屏幕刷新 Else

MsgBox fn.SelectedItems(i) & \不是Excel文件\

End If Next i

ThisWorkbook.Sheets(1).Range(\).SpecialCells(xlCellTypeBlanks).Interior.ColorIndex = 3 '空白单元格填色。

End Sub

Sub ReadB()

Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook

Dim sheet As Excel.Worksheet Dim i as Integer Dim j as Integer

Set xlApp = New Excel.Application

Set xlBook = xlApp.Workbooks.Open(\ Set sheet = xlBook.Worksheets(1)

For i=1 to 22

For j=1 to 110

sheets(1).cells(i,j)=sheet.cells(i,j) Next j Next

xlBook.Close End Sub

本文来源:https://www.bwwdw.com/article/w39.html

Top