复制当前工作表中的所有可见行并将其粘贴到另一个工作表 [英] Copying all visible rows in the current sheet and pasting it to another sheet
本文介绍了复制当前工作表中的所有可见行并将其粘贴到另一个工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了一些代码,但它只选择工作表的第一个单元格,我需要将所有可见的行复制到另一个工作簿。 Do
ActiveCell.offset(1,0)。选择
循环,而ActiveCell.EntireRow.Hidden = True
解决方案
尝试这个
'~~>删除任何过滤器
ActiveSheet.AutoFilterMode = False
'~~>过滤,偏移(排除头文件)
带rRange
.AutoFilter字段:= lCol,Criteria1:= strCriteria
.Offset(1,0).SpecialCells(xlCellTypeVisible).EntireRow.Copy
'
'~~>做任何你想做的,他复制行
'
结束
'~~>删除任何过滤器
ActiveSheet.AutoFilterMode = False
- code> rRange 是Autofilter范围
- 其中
lCol
是相关列。 li>
- 其中
strCriteria
是Autofilter条件
I have a sheet on which I have created a list with a filter set. When I choose some values from that list, then certain values are shown (visible) and the rest are hidden. I just want to copy all the visible data (including all visible rows) from that sheet to another workbook. I have used some code but it only selects first cell of the sheet, and I need all the visible rows to be copied to another workbook.
Range("A1").Select
Do
ActiveCell.offset(1,0).Select
Loop While ActiveCell.EntireRow.Hidden = True
解决方案
Try this
'~~> Remove any filters
ActiveSheet.AutoFilterMode = False
'~~> Filter, offset(to exclude headers)
With rRange
.AutoFilter Field:=lCol, Criteria1:=strCriteria
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Copy
'
'~~> Do whatever you want to do witht he copied rows
'
End With
'~~> Remove any filters
ActiveSheet.AutoFilterMode = False
- Where
rRange
is the Autofilter range - Where
lCol
is the relevant column. - Where
strCriteria
is the Autofilter Criteria
这篇关于复制当前工作表中的所有可见行并将其粘贴到另一个工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文