跳到主要內容

如何從另一個工作表導入數據?

當您操作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從另一個工作表導入數據

Excel的Kutools 還提供 在光標處插入文件 為您解決此問題的功能。

Excel的Kutools 包括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選項卡為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