跳到主要内容

 如何将外部内容粘贴到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中始终匹配目标格式

Kutools for Excel:具有300多个方便的Excel加载项,可以在30天内免费试用,没有任何限制。 立即下载并免费试用!

最佳办公生产力工具

🤖 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 (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