跳到主要內容

 如何將外部內容粘貼到Excel中始終匹配目標格式?

將數據從其他外部應用程序複製並粘貼到工作表時,Excel將使用默認使用的原始格式粘貼數據。 如果需要使用使用的工作表的自身格式粘貼的數據,則粘貼時應根據需要選擇“匹配目標格式”選項。 但是,如果您需要經常應用此選項,當您使用Ctrl + V粘貼數據時,我可以幫助您將此選項設置為默認選項。

將外部內容粘貼到工作表中始終使用Excel選項匹配目標格式

將外部內容粘貼到工作表中始終將目標格式與VBA代碼匹配


將外部內容粘貼到工作表中始終使用Excel選項匹配目標格式

要使Excel以目標格式粘貼數據,可以向您的計算機添加特殊命令 快速訪問工具欄.

1。 點擊 文件 > 選項,並在中 Excel選項 對話框:

  • (1.)點擊 快速訪問工具欄 在左窗格中;
  • (2.)然後選擇 所有的命令從中選擇命令 下拉列表;
  • (3.)然後向下滾動並選擇 粘貼和匹配目標格式 在列錶框中
  • (4.)然後單擊 添加>> 按鈕將此命令添加到 自定義快速訪問工具欄.

文檔匹配目標格式-1

2. 添加此命令後,然後單擊 OK 按鈕關閉此對話框。

3。 而現在, 粘貼和匹配目標格式 已被添加到 自定義快速訪問工具欄,請參見屏幕截圖:

文檔匹配目標格式-2

當您從其他應用程序粘貼數據時,只需單擊 粘貼和匹配目標格式 按鈕在 快速訪問工具欄,內容將粘貼到與工作表的目標格式匹配的工作表上。

注意: 此方法不適用於Excel 2007。


將外部內容粘貼到工作表中始終將目標格式與VBA代碼匹配

使用Ctrl + V和以下VBA代碼時,還可以將“匹配目標格式”設置為默認粘貼選項。

1。 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications窗口.

2。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊窗口.

VBA代碼:將“匹配目標格式”設置為默認粘貼

Sub PasteWithDestinationFormatting()
ActiveCell.PasteSpecial (xlPasteValues)
End Sub

3。 然後保存並關閉此對話框,然後按 Alt + F8鍵 鍵打開 對話。 在裡面 對話框,選擇您在步驟2中創建的代碼名稱,然後單擊 選項 按鈕,然後在出現 宏選項 對話框中,輸入 v快捷鍵 部分,請參見屏幕截圖:

文檔匹配目標格式-3

4. 然後點擊 OK ,在 宏選項 對話框,然後關閉 對話框。

現在,當您將外部應用程序中的數據粘貼到工作表中時, 按Ctrl + V,數據將被粘貼為 匹配目標格式 默認情況下。


相關文章:

在Excel中使用Ctrl + V時,如何將粘貼值設置為默認粘貼?


演示:將外部內容粘貼到Excel中始終匹配目標格式

Excel的Kutools:具有300多個方便的Excel加載項,可以在30天內免費試用,沒有任何限制。 立即下載並免費試用!

最佳辦公生產力工具

🤖 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 (14)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
On "Paste external content to worksheet always match destination formatting with VBA code". After "4. Then click OK in the Macro Options dialog, and close the Macro dialog box". The code would take effect only after saving/closing your worksheet.
This comment was minimized by the moderator on the site
Tried the close and save method. Still running into the same issue that Suneet was.
This comment was minimized by the moderator on the site
Hey, the macro for paste is not working. When I hit CTRL+v, it says: Run-time error '1004': PasteSpecial method of Range class failed
This comment was minimized by the moderator on the site
I'm getting this same error
This comment was minimized by the moderator on the site
Hello, guys,
If you want to paste the contents from website, you should apply the following VBA code.

Sub PasteWithDestinationFormatting()
Dim xRg As Range
Set xRg = Application.InputBox("Please select a cell to paste: ", "Kutools for Excel", , , , , , 8)
If xRg Is Nothing Then Exit Sub
xRg.Range("A1").Activate
ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, DisplayAsIcon:=False
End Sub

After pasting this code into the code module, and then go to the Macro dialog box to set the shortcut.
From now, when pasting contents from other applications, such as Word, website, a prompt box will pop out to remind you select a cell to put the pasting contents, and the contents will be pasted as Match Destination Formatting by default.

Hope it can help you! Thank you!
This comment was minimized by the moderator on the site
What a dick
This comment was minimized by the moderator on the site
That worked, but now I have to double click, or else the Kutools message comes up. Any solution?
This comment was minimized by the moderator on the site
Works for me, just in case somebody needs it.

Sub PasteWithDestinationFormatting()
ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, DisplayAsIcon:=False
End Sub
This comment was minimized by the moderator on the site
it works thanks
This comment was minimized by the moderator on the site
The problem I see after enabling this macro, that works nicely btw,is that my Undo button is greyed out and CTRL+z doesn't work anymore...
This comment was minimized by the moderator on the site
Same, I also cannot use CTRL+Z or and the Undo button is grayed out after using control +Z. But CTRL +V works now to allow me to copy and paste from Google Docs to Excel and have it match the destination format, saving me hundreds of clicks. Thanks!
This comment was minimized by the moderator on the site
i dont know how to thank you for this. its finally solved THANKYOU SOMUCH
This comment was minimized by the moderator on the site
OH MY GOODNESS !!!! YOU LITERALLY ARE A LIFE SAVER!
This comment was minimized by the moderator on the site
This worked for me. Thanks. You just saved me a few hundred clicks a day.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations