【发布时间】:2019-01-11 16:43:17
【问题描述】:
我有工作表(“格式化数据”)和工作表(“Client_1 数据”)
我运行执行以下步骤的宏:
- 选择工作表(“Fromatted Data”)
- 自动过滤列“C”中值为“client_1”的数据
- 从工作表中复制选定的列(“格式化数据”)并将数据粘贴到工作表(“Client_1 数据”)
我的问题是什么:
- 不仅可以复制我过滤的数据,还可以复制所有数据,即使它们不可见。
我的宏代码:
Sub PRINT_AVIVA_ISA()
Sheets("Formatted Data").Select
ActiveSheet.Range("$A$1:$R$73").autofilter Field:=3, Criteria1:=Array( _
"client_1"), Operator:=xlFilterValues
Dim LastRow As Long, erow As Long
LastRow = Worksheets("Formatted Data").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To LastRow
Worksheets("Formatted Data").Cells(i, 2).Copy
erow = Worksheets("Client_1 Data").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Formatted Data").Paste Destination:=Worksheets("Client_1 Data").Cells(erow + 1, 1) ' --- account number
Worksheets("Formatted Data").Cells(i, 3).Copy
Worksheets("Formatted Data").Paste Destination:=Worksheets("Client_1 Data").Cells(erow + 1, 2) ' --- designation
Worksheets("Formatted Data").Cells(i, 4).Copy
Worksheets("Formatted Data").Paste Destination:=Worksheets("Client_1 Data").Cells(erow + 1, 3) ' --- fund name
Worksheets("Formatted Data").Cells(i, 5).Copy
Worksheets("Formatted Data").Paste Destination:=Worksheets("Client_1 Data").Cells(erow + 1, 4) ' --- fund code
Worksheets("Formatted Data").Cells(i, 7).Copy
Next i
End Sub
我需要什么:
- 在我现有的代码中添加一些内容仅复制过滤后的数据?
谢谢,
彼得。
【问题讨论】:
-
我检查了这个并添加了 .SpecialCells(xlCellTypeVisible) 但它不起作用..我做错了什么。