复制当前工作表中的所有可见行并将其粘贴到另一个工作表 [英] Copying all visible rows in the current sheet and pasting it to another sheet

查看:125
本文介绍了复制当前工作表中的所有可见行并将其粘贴到另一个工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张表,我已经创建了一个带有过滤器集的列表。当我从该列表中选择一些值时,会显示某些值(可见),其余值被隐藏。我只想将所有可见数据(包括所有可见行)从该工作表复制到另一个工作簿。
我使用了一些代码,但它只选择工作表的第一个单元格,我需要将所有可见的行复制到另一个工作簿。

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




  1. code> rRange 是Autofilter范围

  2. 其中 lCol 是相关列。 li>
  3. 其中 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

  1. Where rRange is the Autofilter range
  2. Where lCol is the relevant column.
  3. Where strCriteria is the Autofilter Criteria

这篇关于复制当前工作表中的所有可见行并将其粘贴到另一个工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆