Excel VBA复制筛选的选择

时间:2017-09-12 14:59:54

标签: excel vba excel-vba copy autofilter

我有以下代码过滤列,将其粘贴到另一个工作表中

 Sub FilterData()
 Dim rlow As Long, erow As Long, erow2 As Long
 Dim av As Variant, bv As Variant
 Dim p As Long, q As Long

 lrow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Row     
 Worksheets("Wire list").Range("E1").AutoFilter _
 Field:=5, _
 Criteria1:="=S*", _
 VisibleDropDown:=False

 For q = 2 To lrow
      Sheet3.Cells(q, 5).Copy
      erow2 = Sheet2.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).Row
      Sheet1.Paste Destination:=Worksheets("Sheet2").Cells(erow2, 5)
 Next q

 End Sub

问题是正在复制的单元格是q定义的单元格,但我想复制自动筛选的选区。有什么建议?

谢谢!

0 个答案:

没有答案