跳到主要内容

如何从另一个工作表导入数据?

当您操作Excel文件时,您可能希望将一些数据从另一个工作表导入到当前工作表中。 今天,我将为您介绍一些有趣的技巧来解决这个问题。

使用连接功能从另一个工作表导入数据

使用VBA代码从另一个工作表导入数据

使用 Kutools for Excel 从另一个工作表导入数据


箭头蓝色右气泡 使用连接功能从另一个工作表导入数据

如果你所熟悉的 连接 Excel中的“地图项”功能,您可以将另一个工作表数据导入当前工作簿,并且导入的数据将自动使用原始数据进行更新。

1。 点击 时间 > 连接,请参见屏幕截图:

文档导入数据到工作表 1

2。 在 工作簿连接 对话框中,单击 地址 按钮,然后弹出 现有连接 对话框中,单击 浏览更多 按钮,请参见屏幕截图:

文档导入数据到工作表 2
-1
文档导入数据到工作表 3

3。 然后选择您要将其数据导出到当前工作表的工作簿。

文档导入数据到工作表 1

4。 选择工作簿后,请单击 可选 按钮,然后选择一个要使用的工作表。 看截图:

文档导入数据到工作表 1

5。 然后点击 OK,它将返回到 工作簿连接 对话框,并且您选择的工作簿已添加到列表框中,请关闭此对话框。

6。 然后继续点击 时间 > 现有连接,请参见屏幕截图:

文档导入数据到工作表 1

7。 在 现有连接 对话框,单击您刚才添加的工作簿,然后单击 可选 按钮。 看截图:

文档导入数据到工作表 1

8。 并在弹出 导入数据 对话框中,从 选择您要如何在工作簿中查看此数据,然后选择一个现有工作表范围或一个新工作表来放置数据。

文档导入数据到工作表 1

9。 然后点击 OK,另一个工作表中的数据已导入到您指定的工作表中。

文档导入数据到工作表 1

笔记:

1.使用此方法,您可以导入类型为 , 数据透视表报表 or 数据透视图和 数据透视表报表.

2.如果您想在自己的工作簿中获取最新数据,则您的工作簿已连接到该外部数据。 去 时间 > 全部刷新 获取更新的数据。

文档导入数据到工作表 1


箭头蓝色右气泡 使用VBA代码从另一个工作表导入数据

上面的方法有很多步骤,可能会让您感到疲倦,在这里,下面的VBA代码也可以帮助您从另一个工作表导入数据。

1。 按住 ALT + F11 键,然后打开 Microsoft Visual Basic for Applications窗口.

2。 点击 插页 > 模块,然后将以下代码粘贴到 模块窗口.

VBA代码:从另一个工作表导入数据

Sub ImportDatafromotherworksheet()
    Dim wkbCrntWorkBook As Workbook
    Dim wkbSourceBook As Workbook
    Dim rngSourceRange As Range
    Dim rngDestination As Range
    Set wkbCrntWorkBook = ActiveWorkbook
    With Application.FileDialog(msoFileDialogOpen)
        .Filters.Clear
        .Filters.Add "Excel 2007-13", "*.xlsx; *.xlsm; *.xlsa"
        .AllowMultiSelect = False
        .Show
        If .SelectedItems.Count > 0 Then
            Workbooks.Open .SelectedItems(1)
            Set wkbSourceBook = ActiveWorkbook
            Set rngSourceRange = Application.InputBox(prompt:="Select source range", Title:="Source Range", Default:="A1", Type:=8)
            wkbCrntWorkBook.Activate
            Set rngDestination = Application.InputBox(prompt:="Select destination cell", Title:="Select Destination", Default:="A1", Type:=8)
            rngSourceRange.Copy rngDestination
            rngDestination.CurrentRegion.EntireColumn.AutoFit
            wkbSourceBook.Close False
        End If
    End With
End Sub

3。 然后按 F5 键以运行此代码,然后选择要将其数据插入当前工作簿的工作簿,请参见屏幕截图:

文档导入数据到工作表 1

4。 选择工作簿后,然后单击 可选 按钮,然后选择一个工作表或您指定的工作簿范围中需要导出的数据。 看截图:

文档导入数据到工作表 1

5. 然后点击 OK,然后选择一个单元格将导入的数据放入当前工作表中,请参见屏幕截图:

文档导入数据到工作表 1

6。 继续点击 OK,并且所选数据已导入到工作表中。

请注意: 使用此方法,导入的数据将不会用原始数据更新。


箭头蓝色右气泡 使用 Kutools for Excel 从另一个工作表导入数据

Kutools for Excel 还提供 在光标处插入文件 为您解决此问题的功能。

Kutools for Excel 包括300多个便捷的Excel工具。 30天免费试用,不受限制。 立即获取

1。 打开您要插入另一个工作表数据的工作簿。

2。 点击 企业 > 导入/导出 > 在光标处插入文件,请参见屏幕截图:

文档导入数据到工作表 1

3. 而在 在光标处插入文件 对话框中,选择要在其中放置数据的单元格,然后单击“确定”。 浏览 按钮以选择要插入的一个工作簿。

文档导入数据到工作表 1

4。 然后点击 OK,如果您的工作簿包含“选择工作表”对话框中的多个工作表,则选择一个工作表,请参见屏幕截图:

文档导入数据到工作表 1

5。 然后点击 OK,您选择的工作表已导入到您的特定工作表中。

备注:使用这种方法,导入的数据将不会用原始数据更新。

要了解有关此“在光标处插入文件”功能的更多信息。


相关文章:

如何在Excel中导入文本文件或工作表?

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How to import only values with VBA, this VBA paste formulas when importing?
This comment was minimized by the moderator on the site
Amazing, thank you
This comment was minimized by the moderator on the site
This post is FANTASTIC!!!! This is extremely helpful! Thank you!!!
This comment was minimized by the moderator on the site
How can i use relative paths instead of fixed paths,
because these files will be uploaded to SVN and paths will be differ
This comment was minimized by the moderator on the site
This was incredibly useful. Thank you!
This comment was minimized by the moderator on the site
I am using the VBA Code. How can I unhide and remove all filter before select source range?
This comment was minimized by the moderator on the site
Sub Clear()
'
' Clean Sheet
'
Dim A As Long

Sheets("Sheet1").Select
ActiveSheet.Range("Range").Select
Selection.Clear

End Sub


Example
range mean A2:D35
This comment was minimized by the moderator on the site
How do I adapt the VBA code so that it will continuously update with another file?
This comment was minimized by the moderator on the site
I want to learn VBA, can you give me the number of WhatsApp to facilitate communication
This comment was minimized by the moderator on the site
Hit the record button in execl and ALT+f11 look at the code and then change it run it its the way learnt well that was 20year ago
Even know I still hit the record and change it to fix the problem
This comment was minimized by the moderator on the site
Hi, It is very useful for me and my organisation. I need help in this. While connecting the excel files I am not able to open the html links which are there in main file. Please help me out on this.
This comment was minimized by the moderator on the site
How would you adjust the VBA code so that it would paste selections as values?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations