跳到主要内容

如何仅在Excel中将值粘贴到可见/过滤的单元格?

在Excel中,如果您过滤了数据或隐藏了某些单元格,并且将值粘贴到过滤或隐藏的范围内,则隐藏的单元格也会被粘贴的值填充。 在这里,我将告诉您一些技巧,仅将值粘贴到可见单元格中。

使用VBA将值粘贴到可见单元格

使用粘贴到 Kutools for Excel 的可见范围将值粘贴到可见单元格 好主意3


使用VBA将值粘贴到可见单元格

在Excel中,除了VBA,没有其他方法可以解决此问题。

1。 按 Alt + F11键 同时输入一个键 Microsoft Visual Basic应用程序 窗口弹出。

2。 点击 插页 > 模块,然后将以下VBA代码粘贴到弹出的“模块”窗口中。

VBA:仅将值粘贴到可见单元格。

Sub CopyFilteredCells()
	'Updateby20150203
	Dim rng1 As Range
	Dim rng2 As Range
	Dim InputRng As Range
	Dim OutRng As Range
	xTitleId     = "KutoolsforExcel"
	Set InputRng = Application.Selection
	Set InputRng = Application.InputBox("Copy Range :", xTitleId, InputRng.Address, Type: = 8)
	Set OutRng   = Application.InputBox("Paste Range:", xTitleId, Type: = 8)
	For Each rng1 In InputRng
		rng1.Copy
		For Each rng2 In OutRng
			If rng2.EntireRow.RowHeight > 0 Then
				rng2.PasteSpecial
				Set OutRng = rng2.Offset(1).Resize(OutRng.Rows.Count)
				Exit For
			End If
		Next
	Next
	Application.CutCopyMode = False
End Sub

3。 点击 F5 键或 运行 按钮,然后会弹出一个对话框供您选择要复制的值。 看截图:
文档粘贴到可见单元格 1

4.选择值后,单击 OK,然后会弹出另一个对话框,以选择一个范围以粘贴所选数据。 看截图:
文档粘贴到可见单元格 2

5。 点击 OK。 您只能看到可见的单元格粘贴了所选的值。


使用粘贴到 Kutools for Excel 的可见范围将值粘贴到可见单元格

实际上,如果您使用 粘贴到可见范围 实用程序 Kutools for Excel –方便的Excel工具,您可以快速轻松地解决将值粘贴到可见范围的问题。
doc粘贴可见单元格6

Kutools for Excel, 与超过 300 方便的功能,使您的工作更加轻松。 

安装后 Kutools for Excel,请执行以下操作:(立即免费下载Kutools for Excel!)

1.选择要复制和粘贴的值范围,然后单击 库工具 > 范围 > 粘贴到可见范围 > 所有类型 or 仅粘贴值。 看截图:
doc粘贴可见单元格7

2.然后 粘贴到可见范围 对话框弹出,然后选择要粘贴值的范围。 看截图:
doc粘贴可见单元格8

3。 点击 OK。 现在,所选值仅粘贴到可见范围内。

仅将值粘贴到可见单元格 全部粘贴到可见单元格
doc粘贴可见单元格9 doc粘贴可见单元格10


请注意:
此实用程序可用于隐藏和过滤的行或列

单击此处,了解有关粘贴到可见范围实用程序的更多详细信息。

  仅粘贴到可见单元格

最佳办公生产力工具

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

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

kte选项卡201905


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

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (22)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thank you very much hundred times
This comment was minimized by the moderator on the site
After going absolutely crazy trying to find a solution, this worked - specifically, the macro for pasting INTO visible only cells. Note that I was copying only from unfiltered cells. However, the people complaining that it doesn't do both (which I'm not sure is true) should be quiet because it's pretty easy to copy FROM only visible/filtered cells into an unfiltered area. You don't need a macro for that (and if you're trying to do both, just do the copying of filtered cells in Excel first, then use this macro). Again, what Excel is fully unable to do on its own without a macro is to paste to visible cells only. This macro saved my bum. Thanks!
This comment was minimized by the moderator on the site
Thanks for your recognition.
This comment was minimized by the moderator on the site
This worked perfectly, thanks!
This comment was minimized by the moderator on the site
You can also easily do this without a plugin....
CTRL+C the cells you want to paste
Highlight the filtered/partially hidden range you're pasting to
CTRL+G
Select "Special"
Select "Visible Cells Only" & hit OK
CTRL+V
This comment was minimized by the moderator on the site
Thansk for you reply, but it does not work. With your method, it paste all cells including hidden ones with the copied values.
This comment was minimized by the moderator on the site
VBA method did not work! It copied the invisible cells into the visible cells. Now, I realize that the title doesn't say "How to paste values FROM VISIBLE/FILTERED CELLS to visible/filtered cells only in Excel?" but if my workbook is filtered, it's highly possible that this is what is needed. If this is what you want - copy from one section to another (or to simply paste values from certain cells right back to the same cells, so to remove the fomulas) you first need to copy/paste values to an unfiltered workbook/worksheet. THEN you can use the macro...or at least I hope you can. I didn't save my data and UNDO does not work....
This comment was minimized by the moderator on the site
I am sorry for that.
This comment was minimized by the moderator on the site
So is there any update version for this situation?
This comment was minimized by the moderator on the site
It is even more flexible and functional if the inner loop is constructed with Do While loop.
This comment was minimized by the moderator on the site
This was very helpful. Many thanks.
This comment was minimized by the moderator on the site
i am currently developing a macro. In that i need to do filter for a particular column for Eg: Column D and need to paste some values Eg: Valid in column B. only i need to paste the value for the filtered cells. And also i want to know the coding for multiple filters at a time. EG: filtering in one column and checking the value and again do filter in another column without making false for the previous filter. help me on this.
This comment was minimized by the moderator on the site
This works great up to record 1163 of 23,000 and then it stops. Why would it stop?
This comment was minimized by the moderator on the site
You rock! I've had this issue multiple times in the past but it became a back-breaker for the recent project. And you've helped me to fix it beautifully. THANK YOU!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations